- Home /
Question by
Mrofesor · Jan 06, 2017 at 09:54 AM ·
cameracamera rotatecamera followcamera movementcamera rotation
FPS cam for Roll -a-Ball like game
Hi guys ! I've been working on unity for a couple of months but I'm still a beginner to scripting (C#). I'm working on a Roll-A-Ball like game but the difference is that the camera is a fps camera. So what I'm asking for is how can I rotate my ball in the direction of my camera? What I mean is I want my balls forward to be the same with my camera's forward. If I succeed this I will be able to make it compatible with VR platforms.
Comment
Best Answer
Answer by efeguclu · Aug 04, 2017 at 02:31 PM
Attach this script to camera and set player from the Inspector :
using UnityEngine;
public class CameraFollower : MonoBehaviour {
public Transform player;
private void FixedUpdate() {
transform.position = target.position;
transform.rotation = Quaternion.Euler(0f,target.rotation.y, 0f);
}
}
Thanks for the answer :D wasn't working on it since january :) Yardımın için sağol :)