fix inconsistent movement speed change when colliding with solid

0 favourites
  • 8 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • Top-down using a controller thumb-stick for reference.

    When using 8 direction behavior if you approach a solid (wall) at a 45° angle your angle of movement changes to be parallel to the wall in the relative direction you were heading and the speed remains constant.

    When using the custom movement behavior (or bullet) with 360° of movement and you approach a solid wall depending on the direction of approach, the angle of movement appears to be parallel but the movement speed either increases, or decreases drastically depending on the angle of input.

    For example if I approach a wall that is positioned vertically on the y axis at a 45° angle, and when I collide continue to maintain my input, my character moves at a higher movement speed than what is set. If i than rotate the thumb-stick towards the opposite end of the Y-Axis but still towards the wall on the X, the movement speed decreases and my character will not begin moving down the y axis until the stick is quite a way past the centre in the opposite direction. When fully moving the stick to the lowest point on the Y-axis, while still maintaining the contact with the wall, the max movement speed is greatly lower than what is set.

    This happens with standard movement behaviors.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It looks very similar to the issue in this post:

    construct.net/en/forum/construct-3/how-do-i-8/fix-collision-solid-project-150086

    If you are using behaviors to move the character, make sure that your thumbstick code doesn't directly change character's angle or position.

    If this doesn't help, please post your project file.

  • Thanks I didn't see that in the forums. I'll check it out and get back to you

  • dop2000 Implementing 8-way control with the joystick does solve the issue however, the ideal scenario would be to retain 360° movement. Making the playing field even between keyboard and gamepad users is probably better though.

    Out of interest, do you think it is possible to implement a 16-way control using the custom control behavior that would react in the same way as the 8-way to the solid collision issue?

  • I think the best solution is to create the player with two sprites - one invisible PlayerBox with 8-direction behavior, and a visible Player sprite. You can set Player position and angle on every tick, smoothly changing the angle with lerp:

    If PlayerBox is moving:
    Set Player angle to anglelerp(Self.angle, PlayerBox.angle, dt*8)
    

    or

    If PlayerBox is moving:
    Set Player angle to anglelerp(Self.angle, PlayerBox.8direction.MovingAngle, dt*8)
    
  • I already use a separate legs and torso sprite, with the directional behaviour being applied to the legs, which at the moment are invisible. The angle of the torso is controlled by the other analog stick or the mouse.

    What I was wondering was: is it possible to create a 16-way directional movement behaviour? I assume the 8-way uses set vectors to produce the movement, and I guess you could create a 16 vector scenario and divide the analog stick axis' up to match. But the test is, would it react the same way to interactions with solids that 8-way does, or would the original problem persist?

  • I guess it's possible to modify 8direction behavior for 16-direction, but it may be a difficult task.

    You can move your character at any angle by setting vectorX/vectorY. Have you tried it?

    .

  • Yes I can see some issues coming up. I'll try it when I have some more time to dedicate to it and let you know.

    Thanks for your help again!

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