void FixedUpdate() { // Apply movement to rigidbody if (PlayerMovementEnabled) { Vector3 localMove = transform.TransformDirection(moveAmount) * Time.fixedDeltaTime; rigidbody.MovePosition(rigidbody.position + localMove); } // find nearest planet and Allow this body to be influenced by planet's gravity planet = FindClosestPlanet().GetComponent <FauxGA>(); planet.Attract(rigidbody); }
void Awake() { //Cursor, kamera in rigidbody Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; cameraTransform = Camera.main.transform; rigidbody = GetComponent <Rigidbody>(); // Disable rigidbody gravity and rotation as this is simulated in GravityAttractor script rigidbody.useGravity = false; rigidbody.constraints = RigidbodyConstraints.FreezeRotation; //izbor najbljižjega planeta planet = FindClosestPlanet().GetComponent <FauxGA>(); //doda audiosource iz playerju glasba = gameObject.AddComponent <AudioSource>(); }
// Use this for initialization void Awake() { planet = FindClosestPlanet().GetComponent <FauxGA>(); rigidbody = GetComponent <Rigidbody>(); }