i want to make a game about being a gun, so the charecter rotate to the mouse position. The problem is: when i shot, the idea is tha i’m thrown to the oposite direction, but idk how to calculate this vector
here’s my code:
extends CharacterBody2D
@onready var node_2d = $Node2D
var force = 10
var gravity = 570
func _physics_process(delta):
velocity.y = gravity
var mouse_position = get_global_mouse_position()
var dir = (mouse_position - position).normalized()
rotation = dir.angle()
if Input.is_action_just_pressed(“shoot”):
shoot(dir,mouse_position)
I think that using the rigid body could work better than the past two times (characterBody n physicsBody) and then i got the idea that for evite accumulation of impulse, before i add it i set the velocity to complete zero and then apply the impulse
Do you think it could work? (Guess there’s only one way to know)
What do you mean it didn’t work? Was there an error? Did it look wrong? Behave wrong?
Please be specific.
And share your code using the preformatted text with ```
Forget, it i was doing it for the pirate software game jam, and i was already thinking about quitting so I’m out, thanks for the both of you @KingGD and @wchc, if anyone’s reading this for getting help after make your on post.
Bye