I have 2 cannons in my game but I can’t seem to figure a way of limiting their x rotation. I feel like this should be simple but it seems like it’s not.
PLEASE HELP!!!
I have 2 cannons in my game but I can’t seem to figure a way of limiting their x rotation. I feel like this should be simple but it seems like it’s not.
PLEASE HELP!!!
its the applying rotation or something I cant get right.
I am probably overlooking something, but did you try this?
{
int x=45, y, z;
if (x>15 && x<90){
transform.rotation= new Vector3(x, y, z);
}
else {
//throw exception
}
}
Look up Mathf.Clamp in the Scripting Reference.
So it could be cannon.transform.position.x = Mathf.Clamp (cannon.transform.position.x, yourValueOne, yourValueTwo); where Cannon is your Cannon and both yourValueOne and yourValueTwo are your limitations