I am trying to work my way through the tutorial games on the learn section of this. Right now I’m trying to complete the Survival Shooter game. In the tutorial video called player character it says to right Animator anim;
Which WONT work. It doesn’t recognize it as a command. Here’s my entire script. It’s full of errors, even though I’ve checked letter for letter against the one in the “Completed Assets Folder”
Am I missing something? here’s my entire script for PlayerMovement.cs
using UnityEngine;
using UnitySampleAssets.CrossPlatformInput;
public class PlayerMovement : MonoBehaviour
{
public float speed = 6f;
Vector3 movement;
Animator anim;
Rigidbody playerRigidbody;
int floorMask;
float camRayLength = 100f;
void Awake()
{
floorMask = LayerMask.GetMask("Floor")
anim = GetComponent <Animator> ();
playerRigidbody = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
move(h, v);
turning();
Animating(h, v);
}
void move(float h, float, v)
{
movement.Set(h, 0f, v);
movement = movement.normalized * speed * Time.deltaTime;
playerRigidbody.MovePosition(Transform.position + movement);
}
void turning()
{
Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit floorhit;
if (Physics.Raycast(camRay, out floorhit, camRayLength, floorMask))
}
Vector3 playerToMouse = floorhit.point - Transform.position;
playerToMouse.y = 0f;
Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
playerRigidbody.MoveRotation (newRotation);
}
}
void Animating(float h, float v)
{
bool walking = h != 0f || v != 0f;
anim.SetBool("IsWalking",walking);
}
}
