Dynamically fetching an actor's co-ordinates
Posted: Sat Mar 23, 2013 12:03 am
I've been trying to make some reusable functions to ease game development using GE but I keep running into the following issue.
Let's say I have a function that reads the X co-ordinates of one actor and writes this value to the X co-ordinates of another actor. Both actor names should be accessed as parameters in a function, while the code to read and modify the X co-ordinates lies within the body of that function.
For example:
I would then want to call this function by specifying the actor names as parameters.
How would I use actor_to_be_teleported and teleport_location_actor, which contain the names of these actors, to assign the X and Y co-ordinates of one to the other? I can't directly use actor_to_be_teleported.x as that would result in an illegal structure error.
Let's say I have a function that reads the X co-ordinates of one actor and writes this value to the X co-ordinates of another actor. Both actor names should be accessed as parameters in a function, while the code to read and modify the X co-ordinates lies within the body of that function.
For example:
- Code: Select all
void teleport (actor_to_be_teleported, teleport_location_actor) { // Function to teleport an object
// Code to assign the x and y co-ordinates of teleport_location_actor to actor_to_be_teleported
}
I would then want to call this function by specifying the actor names as parameters.
- Code: Select all
teleport("Player_1","Player_2");
How would I use actor_to_be_teleported and teleport_location_actor, which contain the names of these actors, to assign the X and Y co-ordinates of one to the other? I can't directly use actor_to_be_teleported.x as that would result in an illegal structure error.