Getting an actor to constantly face another
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Getting an actor to constantly face another
I'm having trouble using setactorangle to get an actor always look at another actor. It probably requires some sort of math equation which I fail too much at to do?
- LilWhiteMouse
- Posts: 2270
- Joined: Tue Jul 15, 2003 7:00 pm
- Location: Maine, US
- Contact:
This function makes one actor face another:
Then just use this in a script to make your actor face another, where TID1 is the tid of the actor you want to turn, and TID2 is the actor you want it to face.
Code: Select all
function int face (int facer, int target)
{
int x = (GetActorX(target) - GetActorX(facer));
int y = (GetActorY(target) - GetActorY(facer));
SetActorAngle(facer, VectorAngle(x, y));
return 0;
}
Code: Select all
face(TID1, TID2);
- solarsnowfall
- Posts: 1581
- Joined: Thu Jun 30, 2005 1:44 am
You know there's absolutely no reason for that function to return a value. I wrote this explicitly for uses like this. The idea was that it returns an angle that you can do whatever you want with.
Where tid 2 is the actor you want tid 1 to look at.
[edit] Damn you Isle!!!
Code: Select all
Script 1 (VOID)
{
SetActorAngle (1, GetTargetAngle (1, 2));
}
[edit] Damn you Isle!!!

- LilWhiteMouse
- Posts: 2270
- Joined: Tue Jul 15, 2003 7:00 pm
- Location: Maine, US
- Contact: