I'm not very good at programming and I'm in trouble.
I want to acquire multiple items and move to the clear screen.
Even if you get an item, it will not be cleared.Corresponding source code
public class Item: MonoBehaviour
public static bool clear;
private int count;
private void Start ()
clear = false;
count = 0;
void OnCollisionEnter (Collision collision)
if (collision.gameObject.tag == "Player")
count + = 1;
if (count>= 5)
clear = true;
You can move to the clear screen by making one instead of multiple acquisitions.Supplementary information (FW/tool version, etc.)
Answer # 1
Isn't this script attached to each item?
In that case, it seems that the variable count, which counts how many items were taken, is different for each item and is not counted up accurately.
How about counting the items acquired on the player side instead of the item side?
- c # - display multiple selected items with check boxes of xanarinandroid with displayalert
- c # - i want to get 5 items in unity and display the clear screen
- c # - i want to get multiple control names (serial numbers) dynamically
- java - search multiple items about how to write findby 〇 and △ like()
- c # - how to transition from game scene to clear scene (2d)
- c # - i want to create an npc that tracks multiple players by switching targets
- c # - i would like to know how to put delimited data into multiple text boxes from a csv row
- java - i want to set multiple items in the database, but i get an error that the number of arguments does not match
- c # - i want one script to control multiple objects
- c # - how to specify multiple array elements in if statement
- i want to load multiple images with resourcesload () [unity, c #]
- c # - in unity, addforce for multiple objects is stopped at the same position, but there are some variations
- mysql i want to compare multiple items of the same record and get the minimum
- [c #] i want to judge data from multiple devices by serial communication
- how can i move multiple objects with unity c #?
- i want to clear the twitter api call count limit and acquire a large amount of tweet data
- unity camera doesn't have items like clear flags or depth
- [unity] i want to set the position count of the line renderer to 0 with the button [c #]
- c # - i want to display at the previous scroll position when reopening in the scroll view of unity
- c # - i want the player to follow the camera (3d)
- c # - i'm trying not to pick up an item when i have it, but if i pick up the item again, it can be used twice
- c # - the car with wheelcollider does not hit the stage
- c # - i want to get my position in unity 3d and place an object right behind me
- c # - i want to rank in a racing game considering the number of laps unity
- c # - i want to slowly rotate the model to a fixed angle when the flag is set, and slowly return it to the original angle when t
- c # - can i use 3 cameras?
- c # - about unity hinge joint script