Question by
Apexpredator13 · Apr 02, 2017 at 09:59 AM ·
c#camerarotate object
if a camera rotates to a point, make something else move?
Hi all, the camera rotates with the head which is done by moving the mouse, and i am trying to make it so that when you rotate the head to a certain point, the body rotates along with it. here is a copy of my script Script for rotating head using UnityEngine; using System.Collections;
public class playerrotate : MonoBehaviour {
public float SpeedX = 10.0f;
public float SpeedY = 10.0f;
private float pitch = 0.0f;
public float yaw = 0.0f;
// Update is called once per frame
void Update () {
pitch -= SpeedY * Input.GetAxisRaw("Mouse Y");
yaw += SpeedX * Input.GetAxisRaw ("Mouse X");
transform.eulerAngles = new Vector3 (pitch, yaw, 0.0f);
}
}
script for rotating body (one that doesnt work)
using UnityEngine;
using System.Collections;
public class rotatebody : MonoBehaviour {
playerrotate rotate;
void Update () {
if (gameObject.transform.Rotate - GameObject.Find("player").transform.Rotate == 37.893f) {
GameObject.Find ("player").transform.Rotate = new Vector3 (0.0f, rotate.yaw, 0.0f);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Camerashake doesn´t work expected in Build c# 0 Answers
How do I offset a camera when it's position is defined by a VR controller 0 Answers
Change Camera postion 1 Answer
How to change camera on Android? 1 Answer
2D Camera boundaries C# 2 Answers