How do I apply gravity in z axis rather than y?

0 favourites
  • 8 posts
From the Asset Store
Gravity Square is a game where I aim to reach the square at the polka dot door :)
  • Hi Guys,

    I want to be able to through missiles on the flat ground, what I mean is how can I apply physics like the shown image? is it possible? in the other word is is possible to apply the gravity toward z axis? rather than y axis? or since it is a 2D game engine that is not possible?

  • Well, we are looking at a 2D plane so it's going to work on the Y axis anyway. What you could do is add an instance variable, say SpawnY and then add a check when Sprite.Y is > SpawnY - you know it has hit ground and should explode/damage other things, etc.

    Than just make your projectile move in an arch by using whatever - bullet and rotate behaviour or bullet + subtracting from y every tick or just making the movement yourself.

  • You might have to work on some projectile equations/math to get it working the way you intend.

    moving along the x and y axis at a constant rate, while offsetting the missile in the y axis.

  • Just set angle of motion, gravity, speed and acceleration for any object with bullet (make sure you enable it at time of created) and it would work like you wanted.

    No need for equations or variables.

    Set "Set Sprite Angle" to Yes so the object would automatically angle according to its "angle of motion".

    And yes, I have made it to work like that. It's simple.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Many thanks All for all your suggestions.

    sgn15 is there any chance you could make a very simple capx example ?

    Many thanks again.

  • This example may help:

    Z is just the y distance from the shadow on the ground.

  • zardaloop

    I would suggest set all bullets to disabled at the start (bullet properties in sidebar) and enable them using events so you're sure there's nothing flying around when you don't need it. Of course you need at least 1 instance of the bullet object (or rocket in your pic) either in this layout or somewhere else in your project.

    You can adjust all bullet parameters to make it arc even more

    Angle of motion is different when facing left or right (you should know how to count degrees)

    start at 0 degrees at right

    counterclockwise is adding 1 degree

    clockwise is adding -1 degree

    360 degrees in 1 full circle

    360 degrees same as 0 degrees

    research on this if you're not a numbers person

    Set Bullet's "Set Angle" to Yes (bullet properties in sidebar) to angle the sprite of the rocket similar to angle of motion

    Use the sign next to my name (like I did to your name in this post) and I will get a notification and I will reply to you again.

  • Many thanks Guys,

    I have ended up using R0J0hound solution which is exactly what I needed <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> ... ctile.capx

    Many thanks again for all your helps.


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