Velocity to angular Velocity

I’m looking to convert the velocity of a bullet into angular velocity to rotate parts/players

Ideally, this could be done on the server, I’d like to do it with body movers, but in order to do that I need a given Vector3 of the angular velocity which makes it really tricky to combine postion+velocity into the correction rotational velocity. The further the hit is away from the center of mass, the more it should rotate

1 Like

So you want the bullet to hit something, and push on where it hit?

Yeah but the passing the velocity is easy to do, it’s just making them rotate that I’m having issues

Actually no, don’t do that. Let me make a demo place.

Basically what I’m going to do is use the new body movers that operate on Attachments, so they basically calculate all this stuff for you.

When I tried using the new body movers they didn’t work on any part that belonged to a humanoid

From Wikipedia:

local omega = r:Cross(v) / (r.Magnitude ^ 2)

In this case v is the velocity of the bullet, and r is the position where the bullet hit, relative to the block’s position. Because of the cross product being involved, the angular velocity vector would be perpendicular to both the position and velocity. For example if it hits horizontally, the block should only rotate around the Y axis as a result.

1 Like

Don’t do this - use the body movers - I’m making a demo place, it should be done very soon.

I was explaining how to acquire the angular velocity from input vectors, obviously I would recommend using an AngularVelocity constraint instead of manually setting the velocity of parts.

I’m going to use a VectorForce to simulate the force of a bullet on whatever part is hit. Hang tight for the demo.

This demo uses hitscan.

BulletForce.rbxl (33.6 KB)

Live game: Bullet Force - Roblox

Edit: Oops, it looks like there’s an issue with network ownership. Give me a moment.

Edit 2: Fixed network ownership issue, place has been updated, file reuploaded in this post.

Your math works but it has the same issue I was facing to begin with. You can’t put most of the new constraints inside humanoids (owned by a real player). The dummies work perfectly but the players don’t because I’m guessing theres something inside the player module that corrects the orientation

Ok. Let me see if I can fix that. Give me one moment.

Ok. I did your thing. Bullet force is now 5x harder when hitting a player or Humanoid (if they are alive).

The force has always affected players after the network ownership fix, but now it should affect them more if they are alive.

BulletForce.rbxl (33.9 KB)

And as always, live place has updated.

You should join us in the live place, it’s fun. There were like 4 other players but you were nowhere to be found :(

2 Likes

Just so you know, I added more force to humanoids. You can now fling a player off the map by spamclicking them when they spawn.

Dang that actually works really well. The only thing that doesn’t work now is mouse lock forcing the orientation, how exactly do you think I should fix that?

What do you mean by “mouse lock forcing the orientation”?

You can disable mouse lock somewhere I think.

If your in mouse lock, when the server tries to set your orientation it wont be able to because mouselock will instantly reset it

The server isn’t setting your orientation. Since the network ownership fix, the server is telling you to fling yourself if you get hit by a bullet.

You could fix the orientation problem by manually changing the camera orientation when you get hit by a bullet. Or making it follow the player head for 1 step while your character gets deflected by the bullet.