0 Favourites

Touch controls & Collision

  • Hello. I'm new to Construct2 and I'm trying to make a mobile game where you control 2 players via the touch controls. I've got it working so when you are touching the player it'll move its X position to the Touch.X position. The problem I'm having is that you don't stop when you collide with the second player, instead you just pass right through which causes problems because it then stacks them both on top of each other and moves them both at the same time. How can I set it up so when they collide with each other they stop moving or repel from each other or something? Thanks!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • You can easily setup an event for on collision with player2 and do the same for the other player. At that point you can make them react any way you want.

  • OK, so I've found the collision events but how can I make them stop when they collide with each other since they're not technically moving (just being re-positioned). So like how can I stop it from re-positioning them on top of each other or like when they collide it releases the touch controls so they stop moving or something? Thanks.

  • Anyone? <img src="smileys/smiley19.gif" border="0" align="middle" />

  • Why don't you use move commands, instead of manually setting the position every tick?

    Set up a custom movement behaviour and use that to move them to your touch locations, then give them an on collision event that tells them to stop when they bump into each other.

    Alternatively, set your entire "on touch do move" event to be conditional that the two sprites are not overlapping.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)