How to make assemblylinearVelocity go right relative to its object


hi
i’d like the bullet to out right and up out of the chamber

Shell.AssemblyLinearVelocity = Vector3.new(10,10,0)

this is what im trying right now and its not working

You could use CFrames which are relative to the object’s rotation unlike Vector3 positions.

Shell.AssemblyLinearVelocity = (Shell.CFrame.Rotation * CFrame.new(10, 10, 0)).Position
1 Like

You can make ejectionDireciton on the gun and apply:

Caliber.Casing.AssemblyLinearVelocity = EjectionDirection.LookVector * 25 -- change 25 to whatever force
2 Likes

Use CFrame:VectorToWorldSpace().
https://create.roblox.com/docs/reference/engine/datatypes/CFrame#VectorToWorldSpace

2 Likes

@aeroactual this is cleaner than what I suggested you should do this instead.

1 Like

I don’t understand your solution. What is EjectionDirection? That isn’t a built-in class.

1 Like

SuperClass: BasePart
Class: Part

How I implement this for my gun:

image

2 Likes

Ah that makes more sense. Thanks for explaining.

2 Likes

thanks for replies

i cant figure out how to use this for what im trying to do

Shell.AssemblyLinearVelocity = EjectAttach.CFrame:VectorToWorldSpace( Vector3.new(0,0,1) ) * Vector3.new(10,10,0)

Attachment.CFrame is an offset relative to the parent, you need to use Attachment.WorldCFrame instead.

1 Like
Shell.AssemblyLinearVelocity = EjectAttach.WorldCFrame:VectorToWorldSpace( Vector3.new(0,0,1) ) * Vector3.new(10,10,0)

Like this?


It does same thing

CFrame:VectorToWorldSpace() returns a Vector3, using the multiplication operator with another Vector3 just multiplies each component (X, Y, Z). For example, <1, 0, 0> * <10, 10, 10> is <10, 0, 0>.

Do this to fix it:

Shell.AssemblyLinearVelocity = EjectAttach.WorldCFrame:VectorToWorldSpace( Vector3.new(0,0,10) )

Alternatively:

Shell.AssemblyLinearVelocity = EjectAttach.WorldCFrame:VectorToWorldSpace( Vector3.new(0,0,1) ) * 10

-- Equivalent to:
Shell.AssemblyLinearVelocity = EjectAttach.WorldCFrame:VectorToWorldSpace( Vector3.new(0,0,1) ) * Vector3.new(10, 10, 10)
1 Like

Ohh okay thank u , thhis worked
drgdgbd gdg dg

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