Making a pawn go where you want it

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA
Contact:

Making a pawn go where you want it

Post by darksmaster923 » Mon Aug 03, 2009 4:43 am

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?
Herp derp.

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Making a pawn go where you want it

Post by Juutis » Mon Aug 03, 2009 11:41 am

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.
Pain is only psychological.

User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA
Contact:

Re: Making a pawn go where you want it

Post by darksmaster923 » Mon Aug 03, 2009 10:09 pm

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?
Herp derp.

User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA
Contact:

Re: Making a pawn go where you want it

Post by darksmaster923 » Tue Aug 04, 2009 3:02 am

self.camera_pitch is in radians right?
Herp derp.

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Making a pawn go where you want it

Post by Juutis » Tue Aug 04, 2009 12:03 pm

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).
Pain is only psychological.

Post Reply