#Need help on this

1 messages · Page 1 of 1 (latest)

serene sparrow
#

How can I make something similar to this in my game?
When i break a rock or tree i want the items to fall to the ground and then you can pick them up
this is from the game forager

dusty oxide
#

There's multiple things involved in your question.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
serene sparrow
#

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?

dusty oxide