0 Favourites

Custom movement against solid

  • 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.

    Noob.

  • Why not use behaviours?

  • 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.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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)
Similar Topics Posts Views Last Post
Unread hot topic
233 22,244
TiAm's avatar
TiAm
Unread hot topic
0 Favourites
Path Movement Behavior
98 52,469
R0J0hound's avatar
R0J0hound
Unread hot topic
37 4,505
JackieChan's avatar
JackieChan