- Home /
Question by
farbache · Mar 24, 2015 at 06:25 AM ·
javascriptmeleemelee attack
Code don't function when
i made a script: using UnityEngine; using System.Collections;
public class Dungeon : MonoBehaviour {
private GameObject[] jar;
public int qntjin = 1;
public int objetivo;
GameObject Inim;
GameObject[] pork;
public GameObject Player;
public GameObject cuia;
public int qntin = 4;
public GameObject respwn;
public void Start()
{
Inim.SetActiveRecursively(false);
}
public void Update ()
{
jar = new GameObject[1];
jar[0] = GameObject.Find("ho");
for(int y = 0;y<jar.Length;y++)
{
if(jar[y]== null)
{
qntjin--;
}
else
{
qntjin = jar.Length;
y = jar.Length;
}
}
if (qntjin == 0)
{
Player.transform.position = cuia.transform.position;
objetivo = 2;
}
if (objetivo == 2) {
Inim.SetActiveRecursively(true);
Debug.Log("oi");
Inim = GameObject.Find("Inim");
pork = new GameObject[4];
pork[0] = GameObject.Find("pepiggy1l");
pork[1] = GameObject.Find("pepiggy 1");
pork[2] = GameObject.Find("pepiggy 2");
pork[3] = GameObject.Find("pepiggy 3");
for(int r = 0;r<jar.Length;r++)
{
if(pork[r]== null)
{
qntin--;
}
else
{
qntin = pork.Length;
r = pork.Length;
}
}
if (qntin == 0)
{
Player.transform.position = respwn.transform.position;
}
}
}
}
that says if the player destroys a jar he is transported to another room with a enemy, and i have other enemies in the scene and when i activate then the melee doesn't works
melee: #pragma strict
var rayle : int = 10; var target : EnemyHealth;
function Update () {
var hit : RaycastHit;
var fwd = transform.TransformDirection(Vector3.forward);
if (Physics.Raycast(transform.position, fwd, hit, rayle));
{
if(hit.collider.gameObject.tag == "enemy");
{
target= GameObject.Find(hit.collider.gameObject.name).GetComponent(EnemyHealth);
if(Input.GetButtonDown("Fire1"))
{
target.Health -= 100;
}
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613191050im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
How to Do Simple Interactions? 1 Answer
noob question about melee combat 1 Answer
Melee system script help 1 Answer
Brawl style melee combat? 0 Answers