using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Ball_Controller : MonoBehaviour{
public float speed;
private Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody> ();
}
// Update is called once per frame
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 OnTriggerEnter (Collider other){
if (other.CompareTag ("LoadLevelTrigger")) {
other.GetComponent<LoadLevelTrigger> ().LoadDefinedScene ();
}
if (other.CompareTag ("KillZ")) {
int scene = SceneManager.GetActiveScene ().buildIndex;
SceneManager.LoadScene(scene);
}
}
}
I am trying to make my character move in the direction the camera is facing. I am very new to coding but I am trying to do this for a games design class I do. All the answers I find never seem to work (or I am doing something wrong without noticing). If anyone can help me that would be amazing! I have attached my character controller.