Rotating a vehicle
#1

Guys, I am working on a project for my server and I was wondering if there is a way to rotate non-occupied vehicles in 360 degrees ? Even thought I am going to use an object to rotate the vehicles.
Reply
#2

Bump after more than 24 hours.
Reply
#3

pawn Код:
GetVehicleZAngle(currentveh, angle);
SetVehicleZAngle(currentveh, angle);
Reply
#4

Should I make it 360 times to rotate it fully or somehow through a loop ?
P.S: it's a joke about 360 times.
Reply
#5

Bump still need help with it. I tried something and it doesn't work.
Reply
#6

Use a Timer..

Код:
//OnGameModeInit:

SetTimer("RotateVehicle", 1000, 1);

// e.g. bottom of your script:

forward RotateVehicle();
public RotateVehicle()
{
new Float:angle;
GetVehicleZAngle(vehicleid, angle);
SetVehicleZAngle(vehicleid, angle + 5.0); // Turn vehicleid by 5 degrees
}
The vehicle ("vehicleid" has to be replaced by your ID) will now turn by 5 degrees every second.
Reply
#7

Quote:
Originally Posted by Ari
Посмотреть сообщение
pawn Код:
GetVehicleZAngle(currentveh, angle);
SetVehicleZAngle(currentveh, angle);
Quote:
Originally Posted by NaS
Посмотреть сообщение
Use a Timer..

Код:
//OnGameModeInit:

SetTimer("RotateVehicle", 1000, 1);

// e.g. bottom of your script:

forward RotateVehicle();
public RotateVehicle()
{
new Float:angle;
GetVehicleZAngle(vehicleid, angle);
SetVehicleZAngle(vehicleid, angle + 5.0); // Turn vehicleid by 5 degrees
}
The vehicle ("vehicleid" has to be replaced by your ID) will now turn by 5 degrees every second.
Just to clarify guys... Wizzy asked us "is there is a way to rotate non-occupied vehicles in 360 degrees"

Both solutions you have supplied will not work... The SetVehicleZAngle only works when the vehicle is occupied. Making it completely useless in the situation that it's required for. I found this out through extensive bug testing with a vehicle respawn system I scripted. I ended up searching half the world looking for a solution on why the cars weren't rotating the way I'd scripted them too, until I stumbled across a post which actually stated that the "SetVehicleZAngle" function only works when the vehicle is occupied. If it's un-occupied you could pretty much say the script "looks over" it.

However.. I'm not going to leave without providing some kind of solution to you as I did in fact get my system to work. The way I got my system to work was actually by deleting the vehicle, and re-creating it with the same position as before but changing the Z / A (rotational) angle. So something along the lines of:

pawn Код:
//GetVehiclePos(vehicleid, &Float:X, &Float:Y, &Float:Z);

GetVehiclePos(VehID, X, Y, Z);

//GetVehicleZAngle(vehicleid, &Float:Z); -- May I also note that this function works even with un-occupied vehicles. It's only the "SetVehicleZAngle" that doesn't.

GetVehicleZAngle(VehID, A);

//DestroyVehicle(vehicleid);

DestroyVehicle(VehID);

//CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);

CreateVehicle(model, X, Y, Z, A + 360, 0, 0, 5000);
Obviously you'd want to change the colours and what not if this was the steps you were willing to take. I'm unsure if "A + 360" would actually rotate it 360 degrees but it's worth a try. Hope this helped! Good luck with your vehicle rotating!
Reply
#8

Okay guys, thank you for the responses. I will try them now.
Reply
#9

Quote:
Originally Posted by Wizzy951
Посмотреть сообщение
Okay guys, thank you for the responses. I will try them now.
Let us know if you get it working, one thing I don't like is when people fix something and they just say "Fixed it!". There is ALWAYS someone else out there to educate. Good Luck, Wizzy!
Reply
#10

you don't need to destroy the vehicle, using SetVehiclePos will also update the angle for the clients, so set the angle and then set the vehicle position
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)