c sharp angriffs befehl

08/29/2012 00:45 herachiro#1
Hallo Epvpers und zwar arbeite ich mit der unity engine und habe ein player attack geschrieben das mein cube angreifen sollte nur beim compiler bekomme ich nen fehler der nicht angezeigt wird.



Code:
using UnityEngine;
using System.Collections;

public class PlayerAttack : MonoBehaviour {
	public GameObject target;
	public float attackTimer;
	public float coolDown;
	
	void Start () {
		attackTimer = 0;
		coolDown = 2.0f;
	}
	
	void Update () {
		if(attackTimer > 0)
			attackTimer -= Time.deltaTime;
		
		if(attackTimer < 0)
			attackTimer = 0;
		
		if(Input.GetKeyUp(KeyCode.F)) {
			if(attackTimer == 0){
				Attack();
				attackTimer = coolDown;
			}
		}
	}
	
	private void Attack() {
		float distance = Vector3.Distance(target.transform.position, transform,position);
		
		Vector3 dir = (target.transform.position - transform.position).normalized;
		
		float direction = Vector3.Dot(dir, transform.forward);
		
		Debug.Log(direction);
		
		if(distance < 2.5f){
			if(direction > 0){
				EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
				Eh.AddjustCurrentHealth(-10);
			}
		}
	}	
}

vlt arbeitet noch einer mit der Unity 3D Engine und weiß eine lösung zum problem

Mfg Herachiro
08/29/2012 01:24 dowhile#2
Quote:
float distance = Vector3.Distance(target.transform.position, transform,position);
Ich habe keine Ahnung von Untiy oder C#, aber entweder du hast hier ein Leerzeichen nach transform vergessen, oder, was meine Vermutung ist, ein Komma statt Punkt hingeschrieben.
08/29/2012 03:02 herachiro#3
das mit dem komma stimmte aber war nen anderes problem habe es endlich gefunden trotzdem danke :)
09/07/2012 18:58 .Remix#4
PHP Code:
Error E2070 test1.cpp 1Invalid use of namespace 'UnityEngine'
Error E2070 test1.cpp 2Invalid use of namespace 'System'
Error E2040 test1.cpp 4Declaration terminated incorrectly 
;)