Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

ask for help, the rigidbody sword slides sometime #116

Open
pixelcrab123456 opened this issue Jun 29, 2024 · 0 comments
Open

ask for help, the rigidbody sword slides sometime #116

pixelcrab123456 opened this issue Jun 29, 2024 · 0 comments

Comments

@pixelcrab123456
Copy link

pixelcrab123456 commented Jun 29, 2024

Clipchamp.mp4

I dont know could I ask for help there ,I'm using Godot 4.2 with Box2D 0.9.11, the sword moves by rotating, which usually works fine, but sometimes it slides forward as if it has no friction. Could some give me some direction on how to solve this problem?

the sword is rigidbody with a collision polygon2D

the polygon2D:

Screenshot 2024-06-29 022053

the code :
`var torque = 15

func _physics_process(delta):
var mouse_pos = get_global_mouse_position()
var dir_to_mouse = (mouse_pos - position).normalized()
var target_angle = atan2(dir_to_mouse.y, dir_to_mouse.x)

var delta_angle = wrapf(target_angle - rotation, -PI, PI)
var angular_speed = delta_angle * torque
angular_velocity = angular_speed`

I would be very grateful even if someone just gave me a hint.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant