So what I am trying to do is to make Tower look at Zombie using AlignOrientation, however Tower goes crazy and does not look at Zombie properly.
So this is what I have so far. Tower has AlignOrientation in Torso, the Attachment0 is set to Node0 which is located in Torso, and Attachment1 is set to Node1 which is located in Terrain.
In the loop I set Node1 Orientation which is determinated by this:
Node1.WorldOrientation = Vector3.new(Target["Torso"].Position.X, Node1.WorldPosition.Y, Target["Torso"].Position.Z)
-- Target["Torso"] is Zombie's Torso
-- Node1 is the node which is attached to Terrain controlling the tower
Hey there,
I replicated what you intended to do in a baseplate with an R6 figure and an R15 player. See the code below.
Workspace Script
local Node1 = workspace.Terrain.Node1
local Target = workspace.Dummy
while true do
wait()
Node1.WorldOrientation = Vector3.new(Target["Torso"].Position.X+180, Node1.WorldPosition.Y, Target["Torso"].Position.Z+180) -- Add 180 so the zombie orientation flips so the player aligns properly
end
Client Script
wait(5) -- To yield and to test
local AO = Instance.new("AlignOrientation")
local Node0 = Instance.new("Attachment")
Node0.Parent = game.Players.LocalPlayer.Character.UpperTorso -- Change to Torso for R6
AO.Parent = game.Players.LocalPlayer.Character.UpperTorso -- Change to Torso for R6
AO.Attachment0 = Node0
AO.Attachment1 = workspace.Terrain.Node1
In general, doing an infinite while loop is bad practice, I just did it here for your concept. But the best way would be to check if the zombie moves in the world orientation and then run it. This code is not code you would want in your game as it is definitely not the most efficient, but it should help with getting down a solid way of using align orientation.
If it is facing the wrong direction then add 180 to the worldorientation x and z. Align orientation makes the parts fact the same direction. So if the zombie faces the player, the player would face away. That’s why you need the 180.