generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Why won't this properly point towards the player?

Previous Thread :: Next Thread 
badfitz67 is not online. 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 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
22 Dec 2015 10:17 AM
c

You're not going anywhere, bolshevik.
Report Abuse
badfitz67 is not online. 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
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
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 is not online. 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 is not online. 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 is not online. 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
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
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
HumanXerxes is not online. HumanXerxes
Joined: 17 Apr 2011
Total Posts: 1351
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
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image