of     1   

Perci1
#157832695Saturday, March 14, 2015 7:01 PM GMT

I'm currently doing this, which works fine; while true do wait() local plr = playerValue.Value if plr then local direction = (plr.Character.Torso.Position - bot.Torso.Position) * Vector3.new(1, 0, 1) bot.Torso.CFrame = CFrame.new(bot.Torso.Position,bot.Torso.Position + direction) end end with 'playerValue' being an object value equal to the player. However, with lots of NPCs this causes lots of lag. The Script Performance window shows that this is very inefficient, on a large scale at least. Do you know any more efficient method of making the bot face your character?
Wrathsong
#157835660Saturday, March 14, 2015 7:41 PM GMT

ask scripters subforum
charizard45
#157839102Saturday, March 14, 2015 8:25 PM GMT

@above you think with over 2k posts you would have seen atleast once that it states "Scripters" is not for help topics, however the game design section is, are you blind
Sulfone
#157840374Saturday, March 14, 2015 8:40 PM GMT

Loops with very shortest wait() possible are inefficient in general. I recommend having the loop disabled when the player is too far away from the NPC. A separate loop with a high wait such as 10 could be added, with the script right now running whenever the distance away from the player's torso is close enough. Then have the shorter loop break whenever the player is far away enough.
Funse
#157844323Saturday, March 14, 2015 9:25 PM GMT

BodyGyro.
Perci1
#157851301Saturday, March 14, 2015 10:49 PM GMT

The double loop would decrease lag when I'm not near the NPC, but the project I'm working on means that I will be near multiple NPCs at once, and it will still lag the same then. The lag spikes don't tend to happen as much when I'm not near them, anyway. I also don't think I want a such a high delay before the loop actually starts. I don't think a BodyGyro is a good solution. BodyMovers are troublesome, but the BodyGyro's cframe would still need to be set continuously in a loop.
Perci1
#157901481Sunday, March 15, 2015 3:07 PM GMT

bump D:
Perci1
#157929821Sunday, March 15, 2015 8:52 PM GMT

...
Perci1
#157982991Monday, March 16, 2015 2:30 PM GMT

Stop ignoring this...
Perci1
#158080435Tuesday, March 17, 2015 10:34 PM GMT

Well screw Roblox forums.
Perci1
#158138059Wednesday, March 18, 2015 7:40 PM GMT

I was thinking about using the RootJoint but I'm not sure how to use DesiredAngle to face a character.
Johnnya101
#158138182Wednesday, March 18, 2015 7:42 PM GMT

Just an idea, look in the scripts of the gear golden chalice of fame? It has the people spawning all around you, that follow/face you, with no lag. Just an idea.
Perci1
#158140558Wednesday, March 18, 2015 8:19 PM GMT

Thanks, but what that gear does is set AutoRotate to true, then just make the bots walk towards you. This makes them automatically face you, but it won't work for me because my NPC isn't going to always be walking directly towards you.
Goulstem
#158141754Wednesday, March 18, 2015 8:34 PM GMT

local tor = npc.Torso local you = game.Players.LocalPlayer while wait() do tor.CFrame = CFrame.new(tor.CFrame.p,you.Character.Torso.CFrame.p) * CFrame.Angles(math.rad(90),0,0) end I'm not sure if I got the rotations correct, but also a more efficient and smooth way of doing this would be to use BodyGyro.
Perci1
#158142400Wednesday, March 18, 2015 8:42 PM GMT

But that's still in a really fast loop, and a BodyGyro would have to be also in a really fast loop, so it wouldn't really be more efficient, would it?
Goulstem
#158143277Wednesday, March 18, 2015 8:52 PM GMT

game.Players.LocalPlayer.Torso.Position.Changed:connect(function(change) end) I actually don't know if you can use the Changed event off of a property.. but if so dis is efficient pls.
Perci1
#158189542Thursday, March 19, 2015 1:58 PM GMT

You don't use it on a property, but I've tried just using it on the torso, and for some reason when you walk around it's not triggered. If I change the Position in the properties window, it does fire, but me walking around doesn't fire it, oddly enough.

    of     1