Problems with applying forces

Godot Version

4.2.1

Question

Hey I just made like a throwing system for a cube. It’s my first time applying forces to an object in godot and I think I have done something wrong as you can see in the video. Most of the time it works, but sometimes the cube flies further or higher and I don’t know the reason behind that. I have provided code and I put the important parts into green rectangles. Btw the variable called ‘‘onedirection’’ just changes by which way I am looking to either Vector2.RIGHT or Vector2.LEFT. Can someone please help me?


The documentation recommends to use deferred calls to enable / disable collision shapes:
cube_child.get_node("CollisionShape2D").set_deferred("disabled", false)
I don’t know if that’s the issue, but it might be that the cube collides with the player right before the throw. I’d test if leaving the cube collision disabled fixes it.

1 Like

It might have been because of the collision with the player I changed the vector2s from values of 30 to 35 so the starting position of the throw is a little bit further from the player and now I think it seems to be working. Thank you for the reply

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.