#Help Unity Time

1 messages · Page 1 of 1 (latest)

sullen steppe
#

Codes
Pause.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Pause : MonoBehaviour
{

    public GameObject PauseMenu;


    public void PauseGame ()
    {
        Time.timeScale = 0;
        PauseMenu.SetActive(true);
    }

    
    
    
    public void ResumeGame ()
    {
        Time.timeScale = 1;
        PauseMenu.SetActive(false);
    }

    
    
    public void EndGame ()
    {
        Application.Quit();
        Debug.Log("Goodbye!");
    }

    
    
    public void BackToMainMenu ()
    {
        SceneManager.LoadScene("Menu");
    }

}

Player Movement.cs

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class PlayerMovement : MonoBehaviour {

    // This is a reference to the Rigidbody component called "rb"
    public Rigidbody rb;

    public float forwardForce = 2000f;    // Variable that determines the forward force
    public float sidewaysForce = 500f;  // Variable that determines the sideways force

    // We marked this as "Fixed"Update because we
    // are using it to mess with physics.
    void FixedUpdate ()
    {
        // Add a forward force
        rb.AddForce(0, 0, forwardForce * Time.deltaTime);

        if (Input.GetKey("d"))    // If the player is pressing the "d" key
        {
            // Add a force to the right
            rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0);
        }

        if (Input.GetKey("a"))  // If the player is pressing the "a" key
        {
            // Add a force to the left
            rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0);
        }

        if (rb.position.y < -1f)
        {
            FindObjectOfType<GameManager>().EndGame();
        }
    }
}
warm dagger
#

You probably have a class named Time

sullen steppe
#

ah thanks i just move my script now my errors gone!