function Update() {
if(Input.GetButtonDown("KeyBoardAttack(F)"))
{
swordenable();
}
}
function swordenable(){
gameObject.tag = "player_weapon";
print("namechanged");
yield WaitForSeconds(1);
gameObject.tag = "Untagged";
}
Code which solves the previous weeks problem. Now the dagger is only active for one second after you hit the attack button.
Tuesday, October 26, 2010
Week 3: Programming
function OnTriggerEnter(other: Collider)
{
if(other.gameObject.tag == "player_weapon")
{
print("hit");
SendMessageUpwards ("Assasination");
}
}
This code is on a collider behind the enemy and when you sneak up behind him and attack him he will die in one hit. A problem that I am having is that the sword object is always active. So even without hitting the attack button it will kill then enemy. One way to solve this problem is im am going to change the name of the collider for the sword and only change it when the attack button is pressed and then change it back in a couple of seconds.
{
if(other.gameObject.tag == "player_weapon")
{
print("hit");
SendMessageUpwards ("Assasination");
}
}
This code is on a collider behind the enemy and when you sneak up behind him and attack him he will die in one hit. A problem that I am having is that the sword object is always active. So even without hitting the attack button it will kill then enemy. One way to solve this problem is im am going to change the name of the collider for the sword and only change it when the attack button is pressed and then change it back in a couple of seconds.
Tuesday, October 12, 2010
Week 2: Programming
Week 2: Level Design
Subscribe to:
Posts (Atom)