Hi i’ve trying to make a script for selling stuff in my game but every script i make doesn’t work rn i removed all my scripts and I’m going to remake them but i have a simple question how could i make it so if my “item” (that i want to sell) hits a collision sells and gives my player money? could someone please help me with that for that i will need a script for the player’s money and actual selling system
so just for you guys to understand im trying to do this:
i pickup my item and throw it on a box and then it destroys the item that i threw and it gives me money for the item…
ps pls if you are going to give me an example please do it in c#…
You can put code on your item you want to sell that checks for OnCollisionEnter, have it verify it is the correct collider (you don’t want it giving money when contacting just any collider, needs to be the collider for this box you want to put it in), and if so it can give money and call destroy on itself.
Personally I’d make an item script with a variable of the last player that owned it. Then when you collide with the sell box (or whatever it might be) you get the value of the item and add it to the players money then destroy the item.
you need a script that keeps track of how much money the player has,
you need a script on the “sell Item”, When the sell item is sold, it adds money to the money script. Then destroy the “sell Item”