How do I set the position of an object via instance variable

Get help using Construct 2

Post » Wed Jul 20, 2016 12:35 pm

Currently, I am trying to make it so when the player collides with a certain sprite, the player's position will be set to another sprite with a certain instance variable. A better way of putting it is: When the player touches a staircase, they are brought to another staircase. The staircases touch has a variable called "Warp". Each staircase has a different variable. When the player touches a staircase with a warp variable of 0, they are sent to a staircase with the variable of 1. The game this is needed for is a top down shooter.
Oh, okay.
Posts: 41
Reputation: 1,405

Post » Wed Jul 20, 2016 2:06 pm

Have a matching instance variable on your character or whatever is warping, also called warp or playerwarp.

Set the player.warp to match the stairs.warp+1 so it matches to the stairs you want the player to appear at. Do stairs.warp-1 if you want him to go backwards (down the stairs instead of up, etc)

Next compare the values of the variable.warp between stairs and player (for each stairs -> stairs.warp = player.warp)

Then set the player position to the XY of the matching stairs. Then set the player.warp to something like -1 so he can move again to the next stairs. If his varibale remains the same as the stairs he will be unable to move.

Tired of crappy file hosts that are crappy? Get DROPBOX -
Posts: 3,032
Reputation: 30,999

Return to How do I....?

Who is online

Users browsing this forum: Exion and 6 guests