I am currently coding for Unity’s survival shooter tutorial, but my code is not working. Every time i try to run it, it sends back parsing error, though I have no idea what that means. please help.
Please help!!!
I am coding with C#.
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float speed = 6f;
Vector3 movement;
Animator anim;
Rigidbody playerRigedbody;
int FloorMask;
float camRayLength = 100f;
void Awake()
{
FloorMask = LayerMask.GetMask ("Floor");
anim = GetComponent<Animator> ();
playerRigedbody = 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;
playerRigedbody.MovePostion(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);
playerRigedbody.MoveRotation (newRotation);
}
}
void Animating(float h, float v)
{
bool walking = h != 0f || v != 0f;
anim.SetBool ("IsWalking", walking);
}