Bullet with decal on wall

So, imagine we have a working raycast and we have the part and position. How do we create a part, throw a decal on it and position it with the decal facing in the correct direction?
EX of my goal:

1 Like

Also, take in mind the wall may be curved.

I think for this it’d be good if you made a basic part in studio and used it as a template. Customise it all how you want it, and make sure the decal is on the front face of the part.

Then, you simply want to make the part face in opposite direction of the bullet ray – effectively make it look at the ray instead of in front of it.

This could be done simply by doing this, I believe:

Part.CFrame = CFrame.new(HitPosition, HitPosition + -Ray.Direction)

It won’t work for curved walls, however if you used the normal value from FindPartOnRay (without negating it) it should work.

Also you can edit your posts lol

Thanks for the contribution, but I’d like the block to fit into the opposite of my ray. I was thinking of taking the crossproduct method, but I don’t think that will completely work…

Dot product, you mean?

What do you mean ‘opposite of my ray’?

Ok lets trash the idea of the bullet on a decal wall. How about I give an example with parkour. A man trying to run up a wall, how would I CFrame the characters angle to be opposite of that wall and effectively hold him/her there via velocity.

The only problem I’m having is the angle… do I just take the angle of the part and reverse it. I thought about that, but what if we rotated the part, then the algorithm have a major flaw. Thanks. Let me adjust that to my problem.

You mean perpendicular to it?

And edit your posts - stop spamming your own thread.

You could retrieve the wall’s up vector, then offset it by the character’s horizontal position relative to the wall.

local Wall_UpVector = WallPart.CFrame.UpVector -- the direction it looks upwards

local Offset = WallPart.Position - HumanoidRootPart.Position -- get the difference (might be negative)
Offset = Vector3.new(Offset.X, 0, Offset.z) -- use horizontal coordinates only and convert to positive

local HumanoidRootPart_LookVector = Wall_UpVector + Offset

I haven’t tested this code, but if you have any issues it’s probably because A) the first Offset calculation needs to be swapped around or B) the wall’s UpVector isn’t facing up (because you rotated it or something).

So does this solution work for curved walls that maintain an up right format? Also, how would this example work for multiple sides of a wall? How would I configure the equasion to match the rotation if I keep it in an upright position, this problem becomes very complicated… I guess to start I would raycast, but how do I make this work for all sides? How do I check really which side I’m on. Raycast-> Cross character and wall -> Rotate perpendicular(How do I get equasion for side?) So run at it top down design kk.

1 Like

Now that I think about it, it wouldn’t actually set the horizontal rotation at all (i.e. place the character’s feet on the wall).

So, maybe instead of that, set the down vector of the HumanoidRootPart to the inverse of the surface normal on the point hit by the raycast, and offset the HumanoidRootPart from that position using the distance between the center of the HumanoidRootPart and the bottom of a leg (I’ll just say it’s 3.5 studs for now).

Unfortunately I have to go so I won’t be able to write out code for it, however some of this stuff (i.e. using down/up vectors) can be researched on the wiki.

We already effectively know which surface the raycast hits (using the normal) which should be enough in that area.

Break it down into lots of smaller problems. :slight_smile: