- Edited
Hello all,
I've been trying to implement moving platforms in Godot but have some special use cases for my game that I'm running into a wall against. In most cases I could set up a basic moving platform and have my player's velocity match it by applying the get_platform_velocity() function to my player's movement (and using that same value when he jumps to retain velocity). But I have an issue with ledge hanging on moving platforms.
My player body is a capsule using a CharacterBody3D node. The main case where I encounter my issus is when hanging from the corner of a moving platform, the collision body is not always going to maintain contact with the moving platform, causing get_platform_velocity() to be zero. The player will then detach from the platform and fall.
I have two separate solutions in mind for this and would love to hear any thoughts people have about these ideas:
1) Using a RemoteTransform3D:
When player enters a ledge hang state on a moving platform, dynamically create a RemoteTransform3D object in gdscript and pin the player directly to the platform. This is a bit finnicky to set up but if I could get the positioning right I could potentially have this work. I'm unsure the best way to get the player to detach from the RemoteTransform3D node when leaving the platform
2) Reparent the player as a child of the moving platform:
I'm unsure about this. It could work but taking something as major as the player and reparenting them at will seems like code smell or could have some adverse affects I'm not currently privy too later into my project.