Physic-based problems

  • Hello!

    I am currently designing a game where the player must cascade from the sky to the ground while maneuvering around enemies and collecting coins. The protoype is coming out nicely, but I have stumbled upon some physic-based problems that I can't seem to find a solution for (im not a programmer)

    1 - The player has no control of the sprite aside from moving left and right. Adding this was easy using the basic physics behavior. However, when the player moves left and right they do not continue falling. Instead they stop mid-air as long as the key is being pressed.

    2 - I want the player to be able to slow down when holding the up key and speed up when holding the down key. Im not really sure how to code this in the event section.

    Sorry if these questions seem kinda basic, Im still a newbie :(

    Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • BrandonJaySolus

    are you using other movement behaviours alongside physics? They don't get along very well

    if you're using physics, it's best to control all of it's movement with those physics actions

  • Yeah, the 8-directional behavior. I just turned it off and added the apply force event instead. Seems to be working now. Thanks!

    Problem 1 down! (That was fast lol)

  • BrandonJaySolus

    if you want stronger control over the object, you should try using 'Set Velocity'

    if you want to set the X component, but leave Y alone, you can do:

    set X component to [whatever speed you want]

    set Y component to self.physics.velocityY

  • Thanks for the tip. Is there a way to maintain that force and velocity using a variable? So that whenever the player is holding the up/down key their speed remains constant instead of gradually moving towards said angle (which is my main prob atm). I would upload the capx but it seems I cant do that yet (made this account today).

  • If you use key is down - set speed, it should set the speed every tick amd thus the speed would stay the same..

  • That doesn't seem to work (the only Set Speed I see Is in the animation category). My code looks like this

    Conditions

    Keyboard : Up arrow is down

    System: Every tick

    Actions:

    Sprite: Set animation speed to 5

                Apply physics force() at angle () at image point 0

                Set physics velocity to (self.physics.velocityX, 2)

    This for the controlling speed when holding up/down.

  • Ok, so instead of apply force, set the velocity every tick, like keepee said.

    If you use key is down - set VELOCITY, it should set the VELOCITY every tick and thus the speed would stay the same..

  • Ah, i thought I was supposed to have both force and velocity on. Everything seems to work now. Thanks keepee and LittleStain!

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