Final Project
Controls- WASD
Move through the building safely without touching the walls or objects.
Castle
Obstacle course
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GridMovement : MonoBehaviour
{
public Transform playerTransform;
public Vector3 fwd, bwd, lft, rgt;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.W)) {
playerTransform.position = playerTransform.position + fwd;
}
if (Input.GetKeyDown(KeyCode.A)) {
playerTransform.position = playerTransform.position + lft;
}
if (Input.GetKeyDown(KeyCode.S))
{
playerTransform.position += bwd;
}
if (Input.GetKeyDown(KeyCode.D)) {
playerTransform.position += rgt; }
}
}
Main Menu Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour
{
public void PlayGame()
{
SceneManager.LoadScene(1);
}
public void Quit()
{
Application.Quit();
}
}
Movement Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Movement : MonoBehaviour
{
public GameObject GameOver;
public Transform playerTransform;
public Vector3 fwd, bwd, lft, rgt;
// Start is called before the first frame update
void Start()
{
}
void OnCollisionEnter(Collision col)
{
Debug.Log("GAME OVER");
GameOver.SetActive(true);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.W))
{
playerTransform.position = playerTransform.position + fwd;
}
if (Input.GetKeyDown(KeyCode.A))
{
playerTransform.position = playerTransform.position + lft;
}
if (Input.GetKeyDown(KeyCode.S))
{
playerTransform.position += bwd;
}
if (Input.GetKeyDown(KeyCode.D))
{
playerTransform.position += rgt;
}
}
}
GameManager.cs Script
using UnityEngine;
public class GameManager : MonoBehaviour
{
void EndGame()
{
Debug.Log("GAME OVER");
}
}
Leave a comment
Log in with itch.io to leave a comment.