Is there a way to detect if mod car is flipped and way to flip it back over?
Detect if modular car is flipped?
car.transform.SetPositionAndRotation(car.transform.position, Quaternion.Euler(car.GetNetworkRotation().eulerAngles.x, car.GetNetworkRotation().eulerAngles.y, 0)); More to check if on its side is what i need
You can look at the server side code for the push RPC call. There is a check for whether it's upside down.
ya i got the check for upside down Isflipped(); but wonding if there is a way to see if its on its side?
You'll notice it just uses Unity functions.
So your question is more of a unity question, for which there tend to be numerous answers.
https://answers.unity.com/questions/1003884/how-to-check-if-an-object-is-upside-down.html
You could try playing around with the dot product value to see if other values can accurately represent when the entity is on its side.
// BaseVehicle
using UnityEngine;
public bool IsFlipped()
{
return Vector3.Dot(Vector3.up, base.transform.up) <= 0f;
}So your question is more of a unity question, for which there tend to be numerous answers.
https://answers.unity.com/questions/1003884/how-to-check-if-an-object-is-upside-down.html
You could try playing around with the dot product value to see if other values can accurately represent when the entity is on its side.
If you want a visualization for the dot product, this is a helpful tool: https://www.falstad.com/dotproduct/
You can see that the dot product is positive when the angle between Vector3.up and base.transform.up is less than 90, and negative when the angle is greater than 90.