In this script i have created i want the the gameobject to detect if a player or enemy collides with it, then if it does don’t create the block, but destroy itself, but the update gets called before the collision how can i change the script so it works how i want it to?
You could try adding another boolean variable into the OnTriggerEnter function that is set to true whenever a collider enters it. Then, add one more condition to your code in the Update() function that checks to see if that variable is true or not – then run your other conditions within that.
There is no direct way to do this. If you are using a primitive then you can use a sphere cast or a sweep. If you have a more complex collider then the best I’ve seen is to simply wait until after the next FixedUpdate and check if OnTriggerEnter fired.