I would like to know what system should I use in my small survival project. I’ve already created player with FPP. Now it is time to create some events. I wanted my player could for example click bush and some event happend. I’ve tried with OnTrigger, but it was working far away (for exmaple you could pick up some logs from 100 meters). Should I add some coditions and ontrigger is good method or should I use raycasting? I think raycasting is better for FPS not for survival game.
I’ve also don’t know how to check if players is nearby object, watched few youtube videos but i didn’t find any what could help me.
If you have a giant lava lake, then you want some kind of collider on the lava, as well as some way to say “this collider will kill the player” or at least roast him.
If you are talking about picking up a log, raycast is always better, because then if there are 2 logs stacked right next to each other, you can get exactly the one you need.
Remember raycast can also take a length. This keeps it from going infinitely across the map.
Use Physics.Raycast() always with named arguments because it contains many poorly-designed overloads:
Expect to see this error a LOT. It’s easily the most common thing to do when working. Learn how to fix it rapidly. It’s easy. See the above link for more tips.
You need to figure out HOW that variable is supposed to get its initial value. There are many ways in Unity. In order of likelihood, it might be ONE of the following:
drag it in using the inspector
code inside this script initializes it
some OTHER external code initializes it
? something else?
This is the kind of mindset and thinking process you need to bring to this problem: