2 registered members (vicknick, AndrewAMD),
1,292
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Force an object to be in front of the player?
#367634
04/15/11 19:47
04/15/11 19:47
|
Joined: Aug 2007
Posts: 74
Mahdi
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2007
Posts: 74
|
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?
I don't care!
|
|
|
Re: Force an object to be in front of the player?
[Re: Mahdi]
#367635
04/15/11 20:04
04/15/11 20:04
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
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);
|
|
|
Re: Force an object to be in front of the player?
[Re: MasterQ32]
#367639
04/15/11 21:14
04/15/11 21:14
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Or even simpler:
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.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Force an object to be in front of the player?
[Re: Uhrwerk]
#367665
04/16/11 11:04
04/16/11 11:04
|
Joined: Aug 2007
Posts: 74
Mahdi
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2007
Posts: 74
|
Thanks. both of them is something that i need. But Uhrwerk solved the current case easily (as always!).
Thanks again.
I don't care!
|
|
|
Re: Force an object to be in front of the player?
[Re: MasterQ32]
#367681
04/16/11 15:55
04/16/11 15:55
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
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.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
|