Error CS0117 : 'Movement Manager' does not contain definition for 'transform'
I'm working on a script to make my player to be always be looking at the direction he is walking. The original script done by Burdock can be found here http://forum.arongranberg.com/t/direction-of-movement/508/2 I am just trying to get it to work with the most recent version of unity and using a standard character controller but I've ran into an issue
using UnityEngine;
using System.Collections;
using Pathfinding;
using System.Collections.Generic;
public class MovementManager{
public CharacterController controller;
public Transform Player;
protected List<Vector3> LastPositionList = new List<Vector3>();
public Vector3 LastPosition;
void Move (Transform player) {
Player = Player;
controller = Player.GetComponent<CharacterController> ();
}
public void TurnAB(float UnitTurnSpeed, Vector3 LastPosition){
Vector3 LookAt = Player.position - LastPosition;
// This gets the opposite LOCAL position of the *LastPosition*.... IE(If the player is now at 1,1,1 and the LastPosition was 0,0,0.... LookAt will be 1,1,1 in local space, and will be 2,2,2 in world space)
Quaternion LookRotation = Quaternion.LookRotation(LookAt);
// Pretty simple here...
Quaternion rotation = Quaternion.Slerp(Player.rotation, LookRotation , Time.deltaTime * UnitTurnSpeed);
// Pretty simple here too.....
Player.rotation = Quaternion.Euler(0, rotation.eulerAngles.y, 0);
// This just makes sure no *Tilting* happens when, walking up stairs and such
}
void LastPositionCheck(){
if(LastPositionList.Count >= 5){
LastPositionList.Add (this.transform.position); //does not contain definition for 'transform'
LastPosition = LastPositionList[0];
LastPositionList.RemoveAt(0);
}
else{
LastPositionList.Add (this.transform.position); // does not contain definition for 'transform'
}
}
}
If anyone would know why this error is happening and how to fix it would be appreciated.
you need to make sure that your class inherits from $$anonymous$$onoBehaviour if you want to do things with GameObjects.
also, line 16 should probably be:
Player = player;
when posting errors, please include the line number info too...
At lines 35 and 40, this.transform.position looks like it should be Player.position.
'this' refers to the class contained in your script, and there is no variable named transform in your class.
Your answer