Mioxity
(Mioxity)
February 26, 2022, 10:54am
#1
I am making a gun that can shoot balls of acid but I want them to splatter when they touch another part . The problem is I do not know to to make the flat splotches parallel to the surface that the touched . Can someone tell me how to do this as simply as possible?
Puzzled3d
(Puzzled)
February 26, 2022, 1:27pm
#2
This topic has been answered before:
The responses in this thread are incorrect. The surface normal is essentially a vector that points directly away from the surface.
One easy way of using this data is CFrame.new(part_pos, part_pos + normal). This will cause the object to ‘look at’ the surface normal, thus “aligned” with it. You can simply rotate this CFrame to orient it in whichever way you want relative to the surface.
Refer to thread: Explanation of Surface Normal?
So, when confronted with a problem like this, it’s useful to break it down into its simplest parts and start from there.
The way I see it, this is an exercise in vector math and a bit of trig.
In the following example, the goal is to alter the part’s CFrame such that its upVector’s alignment is equal to the direction of the surface normal.
Consider a part whose upVector you want to align with the normal of a part’s surface below it.
First, I define some unit vectors.
local Xunit = Vector3.…
Yep, CFrames are usually a difficult topic that gets little responses.
But also keep in mind that this topic has been solved before. I would google align part to surface.
This is my favorite one which I used to learn CFrames from:
1 Like