If object is moving...

  • I'd like for enemy helicopters to tilt in the direction they are moving, but straighten up when they are not. How do I tell C2 to check if an object is moving positively or negatively along the x-axis?

  • Movement behaviors do often have an "Is moving"-condition and also expressions that return the X and Y vectors.

    Here is a very simple example that should be similar to what you had in mind:

    Download

  • That works great. So "vector" defines the movement direction? This helps a lot. Thank you.

  • I'm still having some difficulty. The enemy helicopter doesn't have "is moving" because it's not controlled by the player and doesn't have an "8Direction" behavior assigned to it. It has a Bullet Behavior assigned to it. VectorX won't work either because it's associated with the "8direction" behavior.

    Is there any other way to achieve this either using the bullet behavior or just checking if the enemy object is moving?

  • That really depends on how you are implementing the movement. A bit of code might clear things up.

  • Yes well, with the Bullet behavior you can work with the "Speed" and "AngleOfMotion"-expressions.

    If the speed is over 0 the sprite is obviously moving and the angles of motion would be 0 for right and 180 for left.

    You might be doing something more complicated, in which case a code snippet would indeed help like blackhornet mentioned.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sure, this is what I have. Bullet behavior is attached to the enemy with set angle off so the enemy is always facing the same direction.

    Enemy - Bullet distance traveled > 150 | Enemy - Set Bullet Speed to 0

    Then I wait a second and send it back the other way. I'd like for it to tilt when moving forward and backward.

  • This is a quick adaption of the previous example to the bullet behavior: Download

  • I tried Comparing Bullet Speed.

    Enemy - Bullet Speed Greater than 0 | Enemy Rotate 1 degrees toward 8.

    But when it moves backwards, it stays at that angle.

  • Awesome! I'm going to study how you did that. Thanks, PixelRebirth.

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