Question by 
               Detera · Aug 10, 2017 at 04:58 AM · 
                jumpcamera-movementtransform.rotation  
              
 
              movement with camera facing and simple jump.
Hi guys, i m new with C# and i need your help. I m trying to made a simple sphere thats move in the direction the camera is facing, when the camera move the axis chiange as well. The problem now is the Jump action, when I press the space key, the sphere jump with an angle of 30 degree because the new y is the camera y and not the world y. Can anyone help me?
[code=Csharp]using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerControllers : MonoBehaviour { public float speed;
 private Rigidbody rb;
 void Start ()
 {
     rb = GetComponent<Rigidbody>();
 }
 void FixedUpdate ()
 {
     
     float moveHorizontal = Input.GetAxis ("Horizontal");
     float moveVertical = Input.GetAxis ("Vertical");
     float jump;
     if (Input.GetKeyDown (KeyCode.Space))
         jump = 30.0f;
     else
         jump = 0;
     
     Vector3 movement = new Vector3 (moveHorizontal, jump, moveVertical);
     movement = Camera.main.transform.TransformDirection(movement);
     movement.y = jump;
     rb.AddForce (movement * speed);
 }
 
               } [code]
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Get camera position back to starting position 0 Answers
Unity 5 Player Control Movement, camera (3rd prs following) jump + gravity 0 Answers
Jump raycast not working 0 Answers
Jump problem 1 Answer