#Need help on this
1 messages · Page 1 of 1 (latest)
There's multiple things involved in your question.
- Breaking objects would require those to be detached from the level's tilemap and hold some kind of script that contains information about their durability and about what they drop.
- Dropping items would require you to spawn item prefabs and then move them in a trajectory. You may be able to do this using Rigidbodies, or you can use kinematic equations to "manually" determine an arc for each drop to follow. Either way, you will probably have to make sure that the items stay on the map so they can actually be picked up.
- Picking up items needs some kind of interaction system. For that, you can use triggers or physics casts. And pickup could be triggered either on input or automatically.
- Lastly, you will want to store how many items of a type you picked up. The simplest way to go about this would be to have a counter variable associated with an item and simply increase that. Depending on your game, you may or may not need a more complex approach - for example including some kind of proper inventory.
i know how to do all this things besides point 2
i dont know how can i make the items drop like that
should i apply some sort of up force?
and what kind of kinematic equations should i use if i do this manually?
If you use Rigidbodies, that would be the preferred way of going about this. Plus perhaps waiting a short (random) time and then resetting the Ribidbodies' velocity, to make it seem like the items landed.
For example, this one https://www.omnicalculator.com/physics/trajectory-projectile-motion#trajectory-formula.
Or this: https://www.youtube.com/watch?v=IvT8hjy6q4o
Depends on your exact approach, really.