Currently I'm making my first video game using unity written in C#, but now I'm facing a trouble and I don't know what to do anymore. First I already made my character move but, I want to put all the attributes in one script, like it's moveSpeed, attackSpeed, etc. but once I access it to another script, my character just stands and do nothing. Here's my code
public class ClickToMove : MonoBehaviour { public CharacterController controller; // Use to move the player private Vector3 position; // Store the position at which the player clicked; public Attributes attribute; // Animation variables public AnimationClip idleClip; public AnimationClip runClip; // Use this for initialization void Start () { position = transform.position; // Set the position to player's current position } // Update is called once per frame void Update () { // Execute the code below once the player press left click if(Input.GetMouseButton(0)) { locatePosition(); } moveToPosition(); } // Locate at which the player clicked on the terrain private void locatePosition() { RaycastHit hit; // Get information from ray Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // A line in 3D space // Cast a ray that start from the camera with a distance of 1000 if(Physics.Raycast(ray, out hit, 1000)) { // Store the position if the casted ray is not pointing to the player or enemy's position if(hit.collider.tag != "Player" && hit.collider.tag != "Enemy") { position = new Vector3(hit.point.x, hit.point.y, hit.point.z); } } } // Move to the located position private void moveToPosition() { // Check if the player position and the destination is greater than one if(Vector3.Distance(transform.position, position) > 1) { // Subtract the clicked position to the player position Quaternion newRotation = Quaternion.LookRotation (position - transform.position); // Disable the rotation from x and z angle newRotation.x = 0f; newRotation.z = 0f; // Rotate the player to a new rotation then move forward transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime * attribute.moveSpeed); controller.SimpleMove(transform.forward * attribute.moveSpeed); animation.CrossFade(runClip.name); } else { animation.CrossFade(idleClip.name); } } } and here is the script I'm accessing
public class Attributes : MonoBehaviour { public float moveSpeed; // Use this for initialization void Start () { } // Update is called once per frame void Update () { } } I don't know what to do anymore. Any help will be appreciated. Thank you.