Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would i make a model look at an moving enemy?

Asked by
VVoretex 146
5 years ago
Edited 5 years ago

I am currently making a tower defense game, and my towers are supposed to aim towards the enemy(its moving along the track) everything in the game is finished, but im stuck on this question and cannot find anything to help.

0
Maybe something to do with CFrame, rotation and or look vector? zomspi 541 — 5y
0
Well, im not fond with CFrame or vector3 VVoretex 146 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Here is your script! (Served hot and ready to go)

1local enemy = workspace.enemy1 -- you could change this to loop over the enemies to find closest one.
2local me = script.Parent
3while true do
4    me:SetPrimaryPartCFrame(CFrame.new(me.PrimaryPart.Position, enemy.Position))   -- there are different types of cframe, this one looks at the point.
5    wait()
6end

if you need more info:

link

Ad

Answer this question