Author Topic: Set vehicle's direction to eye vector  (Read 1571 times)

My function gets the player's eye vector and sets it as %vector. All I need is for it to restore that vector but to %newcar.
Code: [Select]
function Player::startSkiJumping(%obj)
{
//make a new ski vehicle and mount the player on it
%vector = %obj.getEyeVector();
%client = %obj.client;
%position = %obj.getTransform();
%posX = getword(%position, 0);
%posY = getword(%position, 1);
%posZ = getword(%position, 2);
%rot = getWords(%position, 3, 8);
// %obj.playthread(3,shiftdown);
// %obj.playthread(3,sit);

%posZ += 0.3;

%vel = %obj.getVelocity();

%newcar = new WheeledVehicle()
{
dataBlock = skijumpvehicle;
client = %client;
initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
};
// %newcar.setTransform(%newcar.getPosition() SPC %vector);
%newcar.setTransform(%posX @ " " @ %posY @ " " @ %posZ @ " " @ %rot);
%newcar.addVelocity("0 0 5");
// %newcar.setVelocity("0 0 12.5");
%newcar.schedule(150, mountObject, %obj, 0);
%newcar.addVelocity(%vel);
}

You need a rotation, not a vector for the proper use of settransform
I think you need to do eulerangles(%vector)

This doesn't work.
Code: [Select]
function Player::startSkiJumping(%obj)
{
//make a new ski vehicle and mount the player on it

%vector = %player.getEyeVector();
%client = %obj.client;
%position = %obj.getTransform();
%posX = getword(%position, 0);
%posY = getword(%position, 1);
%posZ = getword(%position, 2);
%rot = getWords(%position, 3, 8);
// %obj.playthread(3,shiftdown);
// %obj.playthread(3,sit);

%posZ += 0.3;

%vel = %obj.getVelocity();

%newcar = new WheeledVehicle()
{
dataBlock = skijumpvehicle;
client = %client;
initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
};
%newcar.setTransform(%posX @ " " @ %posY @ " " @ %posZ @ " " @ %rot @ %vectorA);
%newcar.addVelocity("0 0 5");
// %newcar.setVelocity("0 0 12.5");
%newcar.schedule(150, mountObject, %obj, 0);
%newcar.addVelocity(%vel);
%obj.eulerangles(%vector);
// %player.setEyeVector(%vector);
}

%newcar.setTransform(%position);

setTransform takes a transform value

it's the same as position SPC rotation, I believe


but, I still need it to rotate the player on the Z axis to the desired eyevector.
« Last Edit: October 28, 2012, 12:03:55 PM by tommybricksetti »

Basically, I want it so if you're aiming down when you Parkour Physics jump, you'll be facing down in Parkour Physics mode. And if you're aiming up, you'll be facing up.

Basically, I want it so if you're aiming down when you Parkour Physics jump, you'll be facing down in Parkour Physics mode. And if you're aiming up, you'll be facing up.
It's ridiculously painful to do this. I recommend just not doing it, because you have to jump through a million hoops to make the player look at something.

You have to jump through a million hoops to make the player look at something.

Translated: Setting the player pitch at the scripting level on the server's side is not possible.

Translated: Setting the player pitch at the scripting level on the server's side is not possible.
Not entirely true. You can use AIPlayers and their AimAtLocation method to adjust pitch. You may even be able to parent this back onto a player object.

AI Players don't really count as player objects, though; and it's a safe bet that unless there's no control object it won't work on a genuine player (AimAtLocation adjusts aim slowly (from the computer's perspective), so if you called it and then re-added the client's control it would probably cancel the function's control on the player... if it works at all).


One could argue for spawning the client's player as an AI player but that spawns another heap of problems like replicating the entire spawning function correctly including setting the player's shape name (might be possible without hacky badness but I'm not completely sure, never tested) and it might still not work - again, the control object would probably take precedence.



However, you are right in that if you called AIPlayer::AimAtLocation(Player, Vector3D); it would still work in the sense that the script would accept it. What would actually happen is anyone's guess.