Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Eu to colocando esse script numa esfera, e dentro dessa esfera a câmera.
- //Eu só não to conseguindo fazer o personagem se mover em direção a câmera.
- //Eu acho que a solução tem a ver com isso aqui:
- //https://docs.unity3d.com/ScriptReference/Space.html
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Controller : MonoBehaviour {
- public float speed;
- public float speedNormal = 10.0f;
- public float speedFast = 50.0f;
- public float mouseSensitivityX = 5.0f;
- public float mouseSensitivityY = 5.0f;
- float rotY = 0.0f;
- private Rigidbody rb;
- void Start () {
- rb = GetComponent<Rigidbody>();
- }
- void FixedUpdate () {
- float moveHorizontal = Input.GetAxis ("Horizontal");
- float moveVertical = Input.GetAxis ("Vertical");
- Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
- rb.AddForce (movement * speed);
- }
- void Update() {
- float rotX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * mouseSensitivityX;
- rotY -= Input.GetAxis("Mouse Y") * mouseSensitivityY;
- rotY = Mathf.Clamp(rotY, -89.5f, 89.5f);
- transform.localEulerAngles = new Vector3(-rotY, rotX, 0.0f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement