- Home /
Camera And player rotation
I am try to make this game kind of like marble blast. I have so far gotten my player to move forward back side to side and jump. camera follows me but i want it to rotate around my marble and also when i rotate camera then press forward it goes in direction camera rotated i have controlls wasd for move and i wand left right for camera/player rotation up down for height camera here is my player script
var Jumped = false;
function Update () {
if (Input.GetKey ("w"))
{
rigidbody.AddForce (Vector3.forward * 10);
}
if (Input.GetKey ("a")) {
rigidbody.AddForce (Vector3.left * 10);
}
if (Input.GetKey ("d")) {
rigidbody.AddForce (Vector3.right * 10);
}
if(Input.GetKey ("s"))
{rigidbody.AddForce (-Vector3.forward * 10);
}
if(Input.GetKey("space") && !Jumped)
{
rigidbody.velocity += Vector3(0,10,0);
Jumped = true;
}
}
function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.tag == "Floor"){
Jumped = false;}}
function OnCollisionExit(theCollision : Collision){
Jumped = true;}
I then have empy sphere that camera can follow with smooth follow script the scrip for the empty sphere is
var follow : Transform;
function LateUpdate() {
transform.position = follow.position;
}
I am not that good at scripting so please no here is this in c+ you know how to convert or here is the code tweek it for your purposes I just learning thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220613113442im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Third person follow camera on a sphere 1 Answer
Roll-a-Ball Tutorial Camera still doing loop de loop as it follows the sphere. 1 Answer
"Free" rotation about a sphere 0 Answers
Camera/Direction Rotation 2 Answers
Camera rotation around the sphere 0 Answers