- Home /
I am making a fishing game but i can't solve that fishies will die
I have a script on my player the Ontriggerenter so if i collide with a fish he destroys but if there is more than 1 fish in the game he just finds that one look i want to set every fish's collider and renderer enabled but its just one fish here's my script:
function Update () {
//show clone 1
//to do!!!!
if(GameObject.Find("visje1(Clone)")){
//only visje clone
GameObject.Find("visje1(Clone)").renderer.enabled = true;
GameObject.Find("visje1(Clone)").collider.enabled = true;
GameObject.Find("visje1(Clone)").transform.tag = "Visje";
}
if(GameObject.Find("visje1(Clone)").transform.tag == "Untagged"){
GameObject.Find("visje1(Clone)").transform.tag == "Visje";
}
Please help i am just 14 years old.
ps: I am dutch so i can have some spelling mistakes.
Answer by TheShadyColombian · Oct 17, 2014 at 03:31 AM
First let me just say: I'm also 14, high five! And also, that should let you down at all. Now, what I think you should do is make a variable of the number of fishes (visjel? Yay I'm learning Dutch ) then, make a script for your fishes in which it finds the player with the script, and finds the griot itself but specifically the one attached to the player (GameObject.Find("PlayerObjectNameWithQuotes").GetComponent()) so for example, assuming the object with the player script is called PlayerObject and the fishies are called Visjel, and that the player script is called PlayerScript:
public PlayerScript Script;
void Start () {
PlayerScript=GameObject.Find("PlayerObject").GetComponent<PlayerScript>();
}
Then put an ontriggerenter void and inside put " Script.AmountOfFishes+=1; " and I the next line put " Destroy(gameObject); "
first of all thanks for your comment it helped me but what are exactly the things that i have to type in ins$$anonymous$$d of Playerscript just my script or do i have to type more than that
and small fish is indeed visje
Greetings me thanks in advance
Answer by paulonl · Oct 18, 2014 at 12:55 PM
thanks i have got it my script is now:
f(GameObject.Find("visje1(Clone)" || GameObject.Find("visje2(Clone)") || GameObject.Find("visje3(Clone)"))){
GameObject.Find("visje1(Clone)").renderer.enabled = true;
GameObject.Find("visje1(Clone)").collider.enabled = true;
GameObject.Find("visje1(Clone)").transform.name = "visje1(Clone)1";
GameObject.Find("visje2(Clone)").renderer.enabled = true;
GameObject.Find("visje2(Clone)").collider.enabled = true;
GameObject.Find("visje2(Clone)").transform.name = "visje2(Clone)1";
GameObject.Find("visje3(Clone)").renderer.enabled = true;
GameObject.Find("visje3(Clone)").collider.enabled = true;
GameObject.Find("visje3(Clone)").transform.name = "visje3(Clone)1";
}
Case closed
Your answer
![](https://koobas.hobune.stream/wayback/20220613165240im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Raycast ignoring tags problem 1 Answer
Object reference not set to an instance of an object? 1 Answer
How to recalculate collider bounds when i animate a 2d sprite? 1 Answer
Question about FindObjectsOfType 1 Answer
Help With Colliders 3 Answers