Help: Bullet orientation correction

I’ve made a gun and it shoots fine besides the orientation of the bullet. If you don’t know what I mean then here is an example

How it should normally shoot-

vs.

How mine would shoot-

I’ve had problems like these for a long time now and couldn’t find a fix to them.

Here is a key part of my script

local P = {
				density = 100;
				friction = 0;
				elasticity = 0;
				frictionWeight = 0;
				elasticityWeight = 0;
			};
local CPP = PhysicalProperties.new(P.density, P.friction, P.elasticity, P.frictionWeight, P.elasticityWeight)
local Bullet = Instance.new("Part")
			Bullet.Parent = workspace
			Bullet.CanCollide = false
			Bullet.Anchored = false
			Bullet.CustomPhysicalProperties = CPP
			Bullet.BrickColor = BrickColor.new("New Yeller")
			Bullet.Material = Enum.Material.Neon
			Bullet.Size = Vector3.new(0.05, 0.05, 2.9)
			Bullet.CFrame = Barrel.CFrame
			Bullet.Name = Player.Name.."s Bullet"
			
			
			if Mag < 600 then
				local Speed = 0.1
				local Info = TweenInfo.new(Speed, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
				local Properties = {
					Position = Hit.p;
					}
				local NewTween = TweenService:Create(Bullet, Info, Properties)
				NewTween:Play()
				MagAmmo.Value = MagAmmo.Value - 1
1 Like

I don’t know much about that stuff, but the starting position appears to be the place where the player clicks or the “Hit” I believe. Look more into the math behind the angling and positioning.

Maybe have the bullet start: size 0.05, 0.05, 0.05, where the gun’s tip is and then expand it to create the motion effect???

Just rotate the bullet from its CFrame by 90 degrees on the desired axis.

bullet.CFrame = bullet.CFrame * CFrame.Angles(0, math.rad(90), 0)
1 Like

For any other questions on the math behind it, https://developer.roblox.com/en-us/api-reference/lua-docs/math is a simple yet efficient place to visit.

This is likely an issue with how your Barrel is rotated.

See this part:

I have highlighted its front face by going to the Properties widget and selecting FrontSurface.

This allows me to visualize the front-facing surface of the part. Your part is likely oriented towards the right (or left) side:

Which causes the bullet to have the same rotation (front facing left/right).

2 Likes

This fixes 50% of the problem though I already had it like this correctly, I believe I might have a fix to it though… I’m going to make my character face towards my mouse position

You could use CFrame.fromMatrix or the deprecated lookAt constructor to CFrame the Bullet.
More Information about them Here.