- Home /
[Problem] Touch view control goes upside down?
So this is how the view is, but after looking up or down or to the corners using the right joy stick. I have the constraints so that it can only go to a certain height and depth, but still using the corners it still goes upside down.
Problem \/
Here's some of the code:
update(){ lh = CrossPlatformInputManager.GetAxisRaw("RightLeft"); lv = CrossPlatformInputManager.GetAxisRaw("UpDown"); }
void moveController() { player.transform.Translate(h, 0, v); player.transform.Rotate(0.0f,lh*lookSpeed, 0.0f);
if (player.GetComponentInChildren<Camera>().transform.rotation.x < 0.4f && player.GetComponentInChildren<Camera>().transform.rotation.x > -.4f)
{
player.GetComponentInChildren<Camera>().transform.Rotate(-lv, 0.0f, 0.0f);
}
else if (player.GetComponentInChildren<Camera>().transform.rotation.x >= 0.4f)
{
player.GetComponentInChildren<Camera>().transform.Rotate(-0.4f, 0.0f, 0.0f);
}else if(player.GetComponentInChildren<Camera>().transform.rotation.x <= -0.4f)
{
player.GetComponentInChildren<Camera>().transform.Rotate(0.4f, 0.0f, 0.0f);
}
}
Are you trying to move the player and rotate a camera that is childed to the player, but also keep the pitch of the rotation within a set limit? but allow 360 yaw/horizontal rotation?
Yes I am trying to rotate the camera childed to the player so the player will also turn with the camera, allowing it to not move the player when looking up and down though. In this case though when looking up, it does not stop at a certain point and continues until completely upside down.
Your answer
Follow this Question
Related Questions
Mobile Input - Sensitivity, Gravity Matching InputManager's Key 0 Answers
When applying a force to an object on Touch, how do I add a *cooldown* to it? 0 Answers
Trying to rotate my character to the position of my touch on mobile 1 Answer
How to move player using UI buttons, when using Input.mousePosition to shooting? (Android) 0 Answers
Adapting camera movement to touch input 0 Answers