Rotating a vehicle
#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


Messages In This Thread
Rotating a vehicle - by Wizzy951 - 06.02.2014, 17:51
Re: Rotating a vehicle - by Wizzy951 - 07.02.2014, 21:55
Re: Rotating a vehicle - by Ari - 07.02.2014, 22:40
Re: Rotating a vehicle - by Wizzy951 - 07.02.2014, 22:48
Re: Rotating a vehicle - by Wizzy951 - 09.02.2014, 16:27
AW: Rotating a vehicle - by NaS - 09.02.2014, 17:22
Re: AW: Rotating a vehicle - by LiamM - 09.02.2014, 17:57
Re: Rotating a vehicle - by Wizzy951 - 09.02.2014, 20:01
Re: Rotating a vehicle - by LiamM - 09.02.2014, 21:08
Re: Rotating a vehicle - by cessil - 09.02.2014, 23:34

Forum Jump:


Users browsing this thread: 9 Guest(s)