Correctly changing the angle of a monster?
Moderator: InsideQC Admins
6 posts
• Page 1 of 1
Correctly changing the angle of a monster?
I have a monster sending out a traceline, and when the traceline is interupted by a wall i want the monster to face the wall at the correct angle. ive tried many combinations of vectoangles and trace_plane_normal. Is their something i didn't do right?
traceline (self.origin + '0 0 20', self.origin + '0 0 20' + v_forward*50, TRUE, self);
if(vlen(self.origin + '0 0 20' - trace_endpos) < 30)
{
self.angles_y = vectoangles(trace_plane_normal);
}
traceline (self.origin + '0 0 20', self.origin + '0 0 20' + v_forward*50, TRUE, self);
if(vlen(self.origin + '0 0 20' - trace_endpos) < 30)
{
self.angles_y = vectoangles(trace_plane_normal);
}
- Ghost_Fang
- Posts: 336
- Joined: Thu Nov 12, 2009 4:37 am
Re: Correctly changing the angle of a monster?
You're assigning a vector to a float (I suggest getting a good qc compiler, one that lets you know when you've messed up like that (qfcc does, and I think fteqcc does).
Anyway, you'll need a vector temp:
Note, however, that I make no guarantee that you'll get the results you want (in fact, I believe you won't). Quake surface normals can point either way: out of the wall, or into the wall. You'll need to do a dot product of the trace vector with the plane normal to find out whether you need to negate the normal before converting it to angles.
Anyway, you'll need a vector temp:
- Code: Select all
local va = vectoangles(trace_plane_normal);
self.angles_y = va_y;
Note, however, that I make no guarantee that you'll get the results you want (in fact, I believe you won't). Quake surface normals can point either way: out of the wall, or into the wall. You'll need to do a dot product of the trace vector with the plane normal to find out whether you need to negate the normal before converting it to angles.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
Re: Correctly changing the angle of a monster?
And how would i do this?
- Ghost_Fang
- Posts: 336
- Joined: Thu Nov 12, 2009 4:37 am
Re: Correctly changing the angle of a monster?
- Code: Select all
local float dot;
dot = v_forward * trace_plane_normal;
if (dot > 0)
// plane normal goes into the wall
else if (dot < 0)
// plane normal comes out of the wall
else // dot == 0
// how did we hit the wall?
vector1 * vector2 in qc gives the dot product of two vectors.
I very strongly suggest reading up on vector math. Wikipedia is a good place to start.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
Re: Correctly changing the angle of a monster?
taniwha wrote:I very strongly suggest reading up on vector math. Wikipedia is a good place to start.
I am slowly learning vector math through Quake. I've got a ton of books on vector math, but for some reason learning through books feels disgusting to me. I usually learn by practicing first, and then checking out the books to see if there's anything else about the subject. I do feel that I'm being lazy and dumb, though.
-

mankrip - Posts: 915
- Joined: Fri Jul 04, 2008 3:02 am
Re: Correctly changing the angle of a monster?
mankrip: maybe I should have been more explicit, but I didn't mean to read exhaustively. What you're doing is more or less how I got it: play a bit, read a bit, repeat. However, without a bit of reading, it's very difficult to understand just what information a dot product or cross product gives you. It's for that reason I recommend doing some reading.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest