Force an object to be in front of the player?

Posted By: Mahdi

Force an object to be in front of the player? - 04/15/11 19:47

hi,

I asked so many noobish questions for a while. sorry for that.

I need to place an entity pointer in front of player face. so when player rotates, It rotates too but it should still stay in front of player face.

currently I use vec_set to place an entity in front of player face. but when player rotates, the entity does not stay in front of player's face.

could U understand what i mean?

Is there anyway?
Posted By: MasterQ32

Re: Force an object to be in front of the player? - 04/15/11 20:04

rotate your vector you use in vec_set!

VECTOR pos;
vec_set(pos,vector(x,y,z)); //your position here:
vec_rotate(pos,player.pan);
vec_add(pos,player.x);
vec_set(object.x,pos);
Posted By: Uhrwerk

Re: Force an object to be in front of the player? - 04/15/11 21:14

Or even simpler:

Code:
action thinginfrontofplayer()
{
	while(1)
	{
		my.x = sin(player.pan) * 64 + player.x;
		my.y = cos(player.pan) * 64 + player.y;
		my.z = player.z;
		wait(1);
	}
}



... where 64 is the distance from the player to that object.
Posted By: Mahdi

Re: Force an object to be in front of the player? - 04/16/11 11:04

Thanks. both of them is something that i need. But Uhrwerk solved the current case easily (as always!).

Thanks again.
Posted By: MasterQ32

Re: Force an object to be in front of the player? - 04/16/11 11:42

but uhrwerks way has some small problems:
you can never use tilt or roll!
his script only uses pan, so maybe you can get problems if your player tilts!
but if not, then it's okay
Posted By: FoxHound

Re: Force an object to be in front of the player? - 04/16/11 15:55

my.x = player.x + 200 * cos(player.pan);
my.y = player.y + 200 * sin(player.pan);
my.z = player.z + 200 * tan(player.tilt);


That would work on something if you needed it to be in front of the player and the player could fly or something comparable.
© 2024 lite-C Forums