Kazi_1945
(Kazi)
September 23, 2023, 3:28am
#1
Hello! I am currently encountering a problem where, whenever I run the following script, the Bullet (BasePart) goes off course.
local bodyVelocity = Instance.new("BodyVelocity", workspace.Bullet)
bodyVelocity.Velocity = (workspace.Bullet.CFrame * CFrame.new(0,0,100)).Position
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
I also added a stud sized Part to refrence where it’s suppose to go.
However in this video where I am going to provide shows that the Bullet is going off course…
https://streamable.com/t2ki59
ItsEGT
(EGT)
September 23, 2023, 3:30am
#2
Do you just want the bullet to reach the target, or is that just the general direction you want it to be going?
1 Like
Kazi_1945
(Kazi)
September 23, 2023, 3:36am
#3
It’s suppose to go to that direction… The green part is suppose to be there as a REFRENCE , basically if it intersects with it then it’s going in the correct direction else not.
ItsEGT
(EGT)
September 23, 2023, 3:54am
#4
If your goal is to simply go in a certain direction, I would recommend doing this instead of using BodyVelocity
, which is already deprecated anyway.
local RS = game:GetService("RunService")
local bullet = workspace.Bullet
local goal = workspace.Goal
local speed = 100
local direction = (goal.Position - bullet.Position).Unit
bullet.CFrame = CFrame.lookAt(bullet.Position, goal.Position)
RS.Heartbeat:Connect(function(deltaTime)
bullet.CFrame = bullet.CFrame + (direction * deltaTime * speed)
end)
1 Like
Kazi_1945
(Kazi)
September 23, 2023, 4:47pm
#5
Thank you very much! Pardon me for the late response
1 Like
system
(system)
Closed
October 7, 2023, 4:47pm
#6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.