Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / How do I address meshes using Arrays, Types & Functions?

Author
Message
Rick Nasher
2
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 18th Jan 2018 00:53 Edited at: 18th Jan 2018 11:01
Hi guys.

I'm trying to create multiple players using types, arrays and functions.
However I want to keep it as uniform and flexible as possible.

Below is a short working example:


Eventhough in the Function CreatePlayer() to fill all the player type fields I am using GameCharacter[ID].field , for the field GameCharacter[ID].mesh this is a bit more difficult.

I can of course just use: CreatePlayerMesh(ID) and have the field filled in that function, but I much rather would like to keep it uniform with something such as: GameCharacter[ID].mesh = CreatePlayerMesh(ID)
Of course that won't work for the function CreatePlayerMesh(ID) doesn't return a mesh reference like that.

I'm not sure how to put this together so that I can create multiple players using the same functions.


Any advise on this is welcome.
Rick Nasher
2
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 18th Jan 2018 10:49 Edited at: 18th Jan 2018 10:58
Ok edited the example for I realized wasn't too great as to showing what I mean. Hope does now.

What I'm struggling with in the function CreatePlayer( ) is this:

CreatePlayerMesh(ID) // current, simple method of assigning the mesh to the array..
//GameCharacter[ID].mesh = CreatePlayerMesh(ID) ???? // alternative, more uniform, not sure how to pass back the MeshID that I want to create in the function CreatePlayerMesh().
IronManhood
5
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 18th Jan 2018 12:15 Edited at: 18th Jan 2018 12:21
Instead of using separate arrays to store the mesh IDs why not make a mesh type with all the necessary variables to store all the mesh ids for that player. Then, you can pass the new mesh type into the create function by reference to store the ids directly to the player type without having to return the ids and worry about the mess.



Rick Nasher
2
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 18th Jan 2018 14:01 Edited at: 18th Jan 2018 14:05
@IronManhood

Thanks very much for the suggestion. That seems to work really well for adding parts and creating the players how I like it.

However I have one question using this:
When outside of the function createPlayer() , what is the correct way to reference the meshes (or bodyparts )of the individual players in commands such as:
SetObjectPosition(ObjID, x, y, z)
or
SetObjectColor(ObjID, 200,50,50,255) ?
Rick Nasher
2
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 18th Jan 2018 14:37 Edited at: 18th Jan 2018 15:14
Ah nevermind overlooked something, is of course:
SetObjectPosition( players[1].mesh.body_mID, 5,0,0)

AGKs system takes a bit of getting used to.

Again, many thanks.

Login to post a reply

Server time is: 2020-02-16 23:27:38
Your offset time is: 2020-02-16 23:27:38