How can I make while key down always return the same value

0 favourites
  • 8 posts
From the Asset Store
This Girls Game allows young fashionistas to develop their taste and skills as a fashion designer.
  • I'm trying to make the input while the key down always apply the same amount of force, but it keeps adding up and constantly getting faster as I hold the key, how can I keep it to the same value?

  • What behavior are you using - Physics?

  • What behavior are you using - Physics?

    Yes I'm trying to use physics to apply force horizontally while holding a key down but to maintain the same value of force all the time while holding the key and to return to being still after I let go.

    Is that possible?

  • I would suggest using another behavior, but if you absolutely need Physics, you can set velocity instead of applying force.

    Is key down: Object set velocity X to 100

    Else : Object set velocity X to 0

  • I've tried using velocity instead, but in that case, the object moves in the x-axis while not falling anymore, it just keeps going in a straight line "flying" above other surfaces

  • Don't change its Y velocity.

    Why do you need Physics?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I haven't touched the Y value, it's set to 0 as default, should I have done something else?

    I'm trying to make a physical character and I need it to be physical because it switches to another mode/sprite and when in this other mode it disables the controls of the character, and I tried doing that with the platform behavior, but it loses momentum when I switch to the mode without controls, which is why I'm trying to make it with physics, so the momentum is kept the same.

    Another thing is that this other mode will react to the environment like a physical circle colliding around with the map.

  • By setting Y velocity to 0, you are not allowing it to move vertically.

    Use Object.Physics.VelocityY instead of 0.

    .

    If you need to switch between Physics and some other behavior preserving the momentum, you can use velocity values. Say, when switching to Platform, set Platform vectors X/Y to physics.velocityX/Y

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