Forum Thread
  Posts  
How to deal with 0-39 (Forums : Coding & Scripting : How to deal with 0-39) Post Reply
Thread Options
Jul 26 2020 Anchor

Hi MODDB.

I currently have a problem that i can't wrap my head around.

I have a vehicle direction with an output of 0-359 degrees and I wan't other stuff to keep a certain direction (like a weapon system on the roof).

The basic solution would be something like this:

if (weapon_direction < vehicle_direction) 
  {
  //Turn weapon system right
	}

else
  {
  //Turn weapon system left
	}

BUT, the problem occurs when the direction crosses the "0" point resulting in the weapon system going the long way around because it doesn't know that the shortest way from ex 350 degrees to 5 degrees would be to cross that 0-point.


Do you have any ideas of how to do this?

/Morten

Jul 27 2020 Anchor

I have a vehicle direction with an output of 0-359 degrees and I wan't other stuff to keep a certain direction (like a weapon system on the roof). Kodi nox

Edited by: HITASIAQI

Jul 27 2020 Anchor
HITASIAQI wrote:

I have a vehicle direction with an output of 0-359 degrees and I wan't other stuff to keep a certain direction (like a weapon system on the roof). Kodi nox

Sorry, but the links (kodi + nox) doesn't go anywhere?

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.