Hi guys,
trying to help a student figure this out - we have a spiked log in a medieval level that hurts you when you hit by it - it kinda patrols back and forth. So because it hurts you and takes away health points, we need to have the player pushed away from the enemy log else it loses way too many points - plus it would be a nice effect - currently have this -
var startPos : GameObject;
var key: GameObject;
function Update () {
if(transform.position.y < -10.0){
transform.position = startPos.transform.position;
}
}
Which handles our player falling off the map (its an fps controller by the way). And so I tried to take the same principle into this -
var ouchAmount = 1.0;
var ouch : AudioClip;
var startPos : GameObject;
function OnControllerColliderHit (hit : ControllerColliderHit) {
if (hit.collider.gameObject.tag == "log") {
var thePlayer = GameObject.FindWithTag("Player");
thePlayer.transform.position = startPos.transform.position;
Health.health -= ouchAmount;
var owpoint = hit.collider.transform.position;
AudioSource.PlayClipAtPoint(ouch, owpoint);
}
}
which does not work, presumably because unlike the first script, im not within an update function. Can anyone advise??
Many thanks,
Will