I am still super new to unity and coding in general so keep that in mind!
I’m trying to get my walking animation to play as soon as the parameter which i called speed > 0.1
I keep getting the same error and after some googling I still didn’t figure it out.
Assets/Scripts/PlayerMovement.cs(28,26): error CS1061: Type Animator' does not contain a definition for
SetFloat’ and no extension method SetFloat' of type
Animator’ could be found (are you missing a using directive or an assembly reference?)
Any idea what could be wrong?
Heres my script:
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float speed;
public float floatDown;
public Boundary boundary;
Animator animator;
[System.Serializable]
public class Boundary{
public float xMin, xMax, zMin, zMax, yMin, yMax;
}
// Use this for initialization.
void Start () {
gameObject.tag = “Player”;
animator = GetComponent ();
}
// Update is called once per frame.
void Update () {
//Basic left, right, up, down, movement.
float moveHorizontal = Input.GetAxis(“Horizontal”);
float moveVertical = Input.GetAxis (“Jump”);
animator.SetFloat (“Speed”, moveHorizontal);
Vector3 movement = new Vector3 (moveHorizontal, moveVertical, 0.0f);
GetComponent().velocity = movement * speed;
//Clamping so Bubbleboy doesnt exit screen.
GetComponent().position = new Vector3
(
Mathf.Clamp (GetComponent().position.x, boundary.xMin, boundary.xMax),
Mathf.Clamp (GetComponent().position.y, boundary.yMin, boundary.yMax),
Mathf.Clamp (GetComponent().position.z, boundary.zMin, boundary.zMax)
);
//Using relativeForce to simulate floating down.
if (Input.GetKey (KeyCode.S)) {
GetComponent().AddRelativeForce (0, floatDown, 0);
}
}
}