Witam, mam otóż taki problem:
Assets/Player/Scripts/PlayerStats.cs(26,17): error CS0246: The type or namespace name `CharacterMotor' could not be found. Are you missing a using directive or an assembly reference?
Screen z programu: http://zapodaj.net/0cb90f6f26411.png.html
Kod:
using UnityEngine;
using System.Collections;
public class PlayerStats : MonoBehaviour {
private float maxHealth = 100;
private float currentHealth = 100;
private float maxArmour = 100;
private float currentArmour = 100;
private float maxStamina = 100;
private float currentStamina = 100;
private float canHeal = 0.0f;
private float canRegenerate = 0.0f;
public Texture2D healthTexture;
public Texture2D armourTexture;
public Texture2D staminaTexture;
private Vector3 lastPosition;
private float barWidth;
private float barHeight;
public float walkSpeed = 10.0f;
public float runSpeed = 20.0f;
private CharacterController chCont;
private CharacterMotor chMotor;
public GUITexture hitTexture;
void regenerate(ref float currentStat, float maxStat)
{
currentStat += maxStat * 1.90f;
Mathf.Clamp(currentStat, 0, maxStat);
}
void OnGUI()
{
GUI.DrawTexture(new Rect(Screen.width - barWidth - 10,
Screen.height - barHeight - 10,
currentHealth * barWidth / maxHealth,
barHeight),
healthTexture);
GUI.DrawTexture(new Rect(Screen.width - barWidth - 10,
Screen.height - barHeight * 2 - 20,
currentArmour * barWidth / maxArmour,
barHeight),
armourTexture);
GUI.DrawTexture(new Rect(Screen.width - barWidth - 10,
Screen.height - barHeight * 3 - 30,
currentStamina * barWidth / maxStamina,
barHeight),
staminaTexture);
}
void FixedUpdate ()
{
float speed = walkSpeed;
if(chCont.isGrounded && Input.GetKey(KeyCode.LeftShift) && lastPosition != transform.position && currentStamina > 0) {
lastPosition = transform.position;
speed = runSpeed;
currentStamina -= 1;
currentStamina = Mathf.Clamp(currentStamina, 0, maxStamina);
}
chMotor.movement.maxForwardSpeed = speed;
}
void Update ()
{
if(canHeal > 0.0f) {
canHeal -= Time.deltaTime;
}
if(canRegenerate > 0.0f) {
canRegenerate -= Time.deltaTime;
if(canHeal <= 0.0f && currentHealth < maxHealth) {
regenerate(ref currentHealth, maxHealth);
}
if(canRegenerate <= 0.0f && currentStamina < maxStamina) {
regenerate(ref currentStamina, maxStamina);
}
}
}
void takeHit(float demage)
{
if(currentArmour > 0) {
currentArmour = currentArmour - demage;
if(currentArmour < 0) {
currentHealth += currentArmour;
currentArmour = 0;
}
} else {
currentHealth -= demage;
}
if(currentHealth < maxHealth) { // Tego ifa!
canHeal = 5.0f;
}
Destroy(Instantiate(hitTexture), 0.15f);
currentArmour = Mathf.Clamp(currentArmour, 0, maxArmour);
currentHealth = Mathf.Clamp(currentHealth, 0, maxHealth);
}
void Awake()
{
barHeight = Screen.height * 0.02f;
barWidth = barHeight * 10.0f;
chCont = GetComponent<CharacterController>();
chMotor = GetComponent<CharacterMotor>();
lastPosition = transform.position;
}
}