How do I Get platformer negative value on X?

0 favourites
  • 6 posts
From the Asset Store
Make your dream action platformer game effortlessly with this template!
  • Hi, i want set walking animations from the value of platform movement. But it is always positive value. If i move on -X a set it to Left and on positive X a want to set it to walk right. How to do this , because the platform value is always positive number. And i dont want to use pressed arrow keys and such. Thank you.

  • Is there some reason you don't want to use triggers like "is pressing left" to set your animations? It sounds like you're trying to make it hard on yourself for no purpose.

    X position is always going to be positive unless you have unbounded scrolling enabled... 0 is left side of the layout and it only counts up as you move to the right. This is how coordinates work. If you don't want to use the supported triggers for simple actions, then you will need to make some variables that check the position of the player every tick - then compare those values to see if the player moved left or moved right, and set your animations accordingly.

    Honestly though, unless you have some unavoidable necessity to NOT use "is pressing left" (or right) then I would just use those triggers... that's why they're there.

    ~Sol

  • Hi thank you. I want to use values because i use many animations on my player. I have walking , walking shoting, shoting idle, running , running shoting , jumping , jumping shoting, crawl, and so on and it seems too complicated use arrows.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The expression Sprite.Platform.VectorX returns a negative number when moving to the left, positive when moving to the right and zero when idle.

    You can do the mirroring & the walk/idle animations under it, but only under the strict condition that you constrain the logic to catch the exceptions. And there are a lot exceptions.

    When Sprite.Platform.VectorX is less then zero you want the mirroring to happen, but the 'walk' can not happen when in the air, and also not when there is an 'attack' playing.

    The flow and the logic is not that easy. But in the end you will have to catch the 'attack' exception any way, and the 'crunch' and.......... etc.

    .... and the 'is at wall' when using only the triggers to animate, you dont want it to walk when standing still for a wall.

    So in the end, it will be a mix.

    Using the triggers for the 'mirroring', for starting the 'jump' animation, for starting the 'fall' animation, for starting an 'attack' .... & Using the Sprite.Platform.VectorX to fall back on the 2 defaults, "walk' & idle after any of the others ended and there is not other exception in play.

  • Hi thank you. I want to use values because i use many animations on my player. I have walking , walking shoting, shoting idle, running , running shoting , jumping , jumping shoting, crawl, and so on and it seems too complicated use arrows.

    Makes sense, but you can use the arrow keys to simply set a variable (instance or global, whatever suits) just to get a value for the direction. Use this in your comparison event as a flag/trigger for current direction.

    It would however be easier, as suggested by others, to make a variable for curX and curY, and compare to another set of variables like oldX and oldY. This will tell you which direction you are moving and/or facing.

    ~Sol

  • Thank you very much , All your answers , solved the problem.

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