I have searched the forum already and I have watched quite some YT-videos on the topic, but i am still not sure how to continue.
I come from Unity where my Platform-Player is a Rigidbody. When jumping on a moving platform I reparent the node to the platform thus using it coordinates relative to the platform. When leaving the platform or jumping I reset the parent to the World.
I tried this approach in Godot and get viewport is null errors. (I use C#).
Just as in Unity i chose Rigidbody over CharacterBody as base class for my player. I modify the movement within processPhysics but i do not use the integrateForces method (just in case it is related to my current problem).
My moving platform has an Area2D that indicates the player is entering or leaving the platform.
private void _on_area_2d_body_entered(Node2D body)
{
if( body.IsInGroup("player"))
{
Node2D platform = GetNode("Platform") as Node2D;
body.GetParent().RemoveChild(body);
platform.AddChild(body);
}
}
This is how i try to reparent. The game now freezes and i get get_viewport is null errors.
For more information feel free to ask.
Question: How can i best implement the desired behaviour of my moving platform - best without changing too much of my player since the movement finally feels smooth.