Hi there! I'm like many now transitioning from Unity to Godot 4.1 but I only quite recently started trying my hand at game developing (and code).
I am struggling to replicate everything I have in Unity like how my tank (RigidBody2D with collision polygon) behaves when colliding with something:
https://youtu.be/4Aj60v9hVLY
the rocks are static body but they behave the same if they are character body.
The tank is propelled by continuous force (impulse) when you press the controls.
I've tried changing various values in the inspector: mass, inertia, friction, damp, damp mode, disable mode..
func control(delta):
# Apply a force to the tank in the direction of the player's input.
if Input.is_action_pressed("forward"):
var impulse = Vector2(moveForce, 0).rotated(rotation)
apply_central_impulse (impulse)
if Input.is_action_pressed("back"):
var impulse = Vector2(-moveForce/2, 0).rotated(rotation)
apply_central_impulse (impulse)
# Apply a torque to the tank in the direction of the player's input.
if Input.is_action_pressed("turnRight"):
apply_torque_impulse(rotationSpeed)
if Input.is_action_pressed("turnLeft"):
apply_torque_impulse(-rotationSpeed)
func _process(delta):
control(delta)