badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 22 Dec 2015 09:58 AM |
I'm making a turret that tracks player movement in a certain radius. spawn(function() while wait(Upd_Delay) do tracking = findNearestTorso(turTop.RPart.Position) if tracking then turTop:SetPrimaryPartCFrame(CFrame.new(turTop:GetPrimaryPartCFrame().p, tracking.Position)) end end end) (findNearestTorso is just an editted version of a zombie "AI", it's completely irrelevant to my problem, it only get's the nearest torso to the turret)
when I run it, it tracks the player but isn't actually pointing at them.
Here's a gif of what's happening(sorry about the low quality, converted it from AVI to gif): https://twitter.com/DucktorCid/status/679330071832866816
You're not going anywhere, bolshevik. |
|
|
| Report Abuse |
|
|
badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 22 Dec 2015 10:17 AM |
c
You're not going anywhere, bolshevik. |
|
|
| Report Abuse |
|
|
badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 22 Dec 2015 11:02 AM |
Also, I've checked all the part's axis', they're fine.
You're not going anywhere, bolshevik. |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2015 11:12 AM |
t is probsbly just a bug, so check all of your assumptions, and you will find th problem: (I'll start you off)
What-ever Part that you assume is the Primary Part is NOT the Primary Part...... or The Primary Part's 'Front' Face is not in line with the gun.... or (The list of Assumptions is infinite......)
GL, Brian
|
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 22 Dec 2015 11:14 AM |
so does it follow you from wrong surface?
can't really see that from the gif because you aren't going all around it
|
|
|
| Report Abuse |
|
|
badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 22 Dec 2015 11:18 AM |
Fixed it.
You're not going anywhere, bolshevik. |
|
|
| Report Abuse |
|
|
badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 22 Dec 2015 11:19 AM |
Is it possible to only allow it to only rotate on it's Y axis to track the player, if they get close, it starts to point up.
You're not going anywhere, bolshevik. |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2015 11:22 AM |
Bad,
yeah, don't let anyone know what was wrong, in order to help other people (even if it might make you look silly.... Humility is attractive, ya know......).
|
|
|
| Report Abuse |
|
|
|
| 22 Dec 2015 11:26 AM |
Looks like it's following, just at the wrong angle. Try this:
spawn(function() while wait(Upd_Delay) do tracking = findNearestTorso(turTop.RPart.Position) if tracking then turTop:SetPrimaryPartCFrame(CFrame.new(turTop:GetPrimaryPartCFrame().p, tracking.Position)*CFrame.Angles(0,math.pi/2,0)) end end end)
If the turret is backwards now, try:
spawn(function() while wait(Upd_Delay) do tracking = findNearestTorso(turTop.RPart.Position) if tracking then turTop:SetPrimaryPartCFrame(CFrame.new(turTop:GetPrimaryPartCFrame().p, tracking.Position)*CFrame.Angles(0,-math.pi/2,0)) end end end) |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2015 11:29 AM |
stript the Y Value (This Will have bugs, bwcaue I'm doing it 'on-the-fly'):
tracking = findNearestTorso(turTop.RPart.Position) if tracking then local Y = turTop:GetPrimaryPartCFrame().p.y -- or what-ever gets you Primary Part's Y Value.
local TR = Vector3.new(tracking.Position.x, Y, tracking.Position.z)
turTop:SetPrimaryPartCFrame(CFrame.new(turTop:GetPrimaryPartCFrame().p, TR))
|
|
|
| Report Abuse |
|
|
badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 22 Dec 2015 11:48 AM |
@BJ
you mentioned it. The front wasn't facing foward, it was facing right
You're not going anywhere, bolshevik. |
|
|
| Report Abuse |
|
|