Page 1 of 1

Making a pawn go where you want it

Posted: Mon Aug 03, 2009 4:43 am
by darksmaster923
I want to have a pawn that goes to a spot where my crosshair is. Basically, I look at a point in the ground and the pawns will go to the spot. It's pretty hard though, any ideas how to do this?

Re: Making a pawn go where you want it

Posted: Mon Aug 03, 2009 11:41 am
by Juutis
You could measure the distance between the camera and the spot where the crosshair is pointing with GetCollideDistance() and with a bit of trigonometry you should be able to calculate the X, Y and Z coordinates of that point.

Another option that crossed my mind is to launch a pawn from the camera's position to the crosshair's direction and mark the spot where it collides with the ground.

Re: Making a pawn go where you want it

Posted: Mon Aug 03, 2009 10:09 pm
by darksmaster923
I was considering trig by getting the pitch of the camera then using tan, but I wanted to try the projectile idea first. how would you find the point where the pawn hits the ground?

Re: Making a pawn go where you want it

Posted: Tue Aug 04, 2009 3:02 am
by darksmaster923
self.camera_pitch is in radians right?

Re: Making a pawn go where you want it

Posted: Tue Aug 04, 2009 12:03 pm
by Juutis
Yep, all the pitches and yaws are in radians.
how would you find the point where the pawn hits the ground?
Use a pawn with a small bounding box and fly to the camera's direction with flymove(). When flymove() returns false the pawn has collided with something and that's your point (the pawn's X, Y and Z coordinates).