I’ve been bashing my head against this issue for hours, time to ask for help…
I’m making a derivative of Hoppy Days, with moving platforms, some of which move up and down vertically.
The problem: when player character (PC) lands on a vertical motion platform while the platform is moving up, it gets vertically stuck and can’t jump off it. PC can, however, walk off it. When trying to jump, the audioplayer (implemented as in Hoppy Days) makes a buzzing sound, as if trying to play, then terminating.
Some constraints, and other potentially relevant info:
-
Player should move along with platform while idle on it. As of now, I’ve tried implementing this through platform collision detection, with a callback to the player, passing platform node as argument, and player updating its motion vector as platform velocity in every physics_process() call. I’ve commented this functionality out, and bug still there.
-
Player should be unaffected by player movement.
-
Platform needs collision detection. Platform locations and movement directions are procedurally (semi-randomly) generated, and reverse direction when colliding with anything except PC.
-
Level is implemented as an “arena”, totally enclosed by floors, walls, and ceiling. Game is intended for very young children - no losing lives or falling off the world. I have implemented arena walls as StaticBody2D.
What I’ve tried so far:
-
Implemented MovingPlatform as:
– StaticBody2D, decorated with Area2D for collision detection. Exhibits jump bug as described.
– Area2D. PC simply falls through - I can’t seem to make the PC move along with the platform.
– KinematicBody2D, decorated with Area2D. Platforms stick to floor of arena. Can’t seem to get it to reverse direction.
– RigidBody2D. Many undesired behaviors. Pretty sure this is not the way to go, as I don’t want the platform itself affected by the physics engine. -
Some tweaks to player mechanics:
– When trying to jump, move player slightly up first, then add velocity.
– Setting PC collision safety margin low (0.01)
I saw a potentially related thread here on the forum, but I didn’t see a conclusive solution. Anybody have a clear solution to setting this up properly?
I will post a reply to this with code.