Custom movement against solid

0 favourites
  • 4 posts
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • Dear all,

    I'm trying to learn to use C2 without the use of behaviours (am I on a hiding to nothing here?) and am trying to get one sprite to interact with another - as much as a player object would against a solid.

    The only way I can think of doing this is to check the collision status after the key press and coord update, but before these changes are submitted to the screen ...and cancelling the change if there is a collision.

    I'm just darned if I know how to do this in C2.

    Any pointers much appreciated.


  • Why not use behaviours?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is a basic way to do it:

    Every Tick:

    + Sprite: set X to: Sprite.X + 1

    Sprite: is overlapping Wall:

    + Sprite: set X to: Sprite.X - 1

    If the motion is more complex another way to do it would be to save the sprite's x,y position in variables before moving the sprite. Then if it collides with a wall you can undo the motion by setting the sprite's position to the values in the variables.

  • I'd personally put another, invisible sprite behind the main one, making it slightly (depending on the speed of the game) larger than the main one. Then use that to tell your collision, in the sense that if the right-hand side of the object is colliding with a wall, ignore the invalid input.

    There are several ways to do this, but I'd recommend behaviors.

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