A simple 3d Vector Question...?
by DALO · in General Discussion · 04/01/2008 (9:57 am) · 3 replies
Hey All,
For some reason I'm having a big ol brain fart so I thought I'd try posting my first qustion in the general discussions. In the game that I am creating my player will activate a portal which he will be running through. When the player does run through the portal it keeps his velocity and when he spawns at a different point in the game he will come flying out of the portal based on the world's forward vector y. The player will be facing based on the spawn points y vector but his velocity is based on the world's y vector, not a local vector.
How do I get my player to maintain his velocity based on the spawn points forward vector? Any ideas?
Thx.
For some reason I'm having a big ol brain fart so I thought I'd try posting my first qustion in the general discussions. In the game that I am creating my player will activate a portal which he will be running through. When the player does run through the portal it keeps his velocity and when he spawns at a different point in the game he will come flying out of the portal based on the world's forward vector y. The player will be facing based on the spawn points y vector but his velocity is based on the world's y vector, not a local vector.
How do I get my player to maintain his velocity based on the spawn points forward vector? Any ideas?
Thx.
#3
// my pickSpawnPoint function picks a random spawn point of many and returns the id of the spawn point.
%spawnHere = pickSpawnPoint(%obj.client);
// now that I have the spawn point, the spawn point's forward vector(based on the green y arrow) is the
// direction and forward velocity I want to be going when transforming.
// %obj is my player, so now I'm setting my player to face the same direction as the spawn point.
%obj.setTransform(%spawnHere.getTransform());
// now that my player is set in the right direction, let's get the spawn points forward x,y and z forward vector.
// the *30 is the variable that you want to change to increase/decrease there velocity when coming out
// from the spawn point.
%x = getWord(%spawnHere.getForwardVector(), 0) * 30;
%y = getWord(%spawnHere.getForwardVector(), 1) * 30;
%z = getWord(%spawnHere.getForwardVector(), 2) * 30;
// now set velocity to what the spawn points forward vector * 30.
%obj.setVelocity(%x SPC %y SPC %z);
Hope this comes in handy for others down the road......
D.
04/03/2008 (10:24 am)
Ok, I have a solution.// my pickSpawnPoint function picks a random spawn point of many and returns the id of the spawn point.
%spawnHere = pickSpawnPoint(%obj.client);
// now that I have the spawn point, the spawn point's forward vector(based on the green y arrow) is the
// direction and forward velocity I want to be going when transforming.
// %obj is my player, so now I'm setting my player to face the same direction as the spawn point.
%obj.setTransform(%spawnHere.getTransform());
// now that my player is set in the right direction, let's get the spawn points forward x,y and z forward vector.
// the *30 is the variable that you want to change to increase/decrease there velocity when coming out
// from the spawn point.
%x = getWord(%spawnHere.getForwardVector(), 0) * 30;
%y = getWord(%spawnHere.getForwardVector(), 1) * 30;
%z = getWord(%spawnHere.getForwardVector(), 2) * 30;
// now set velocity to what the spawn points forward vector * 30.
%obj.setVelocity(%x SPC %y SPC %z);
Hope this comes in handy for others down the road......
D.
Dwane Seward
orange.half-life2.com/portal.html
i hope I've been April fooled... :P