Object destruction in unity?

Updated on August 26, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
5 on July 28, 2018

I’m trying to create a full game styled similarly to a mini game I like. However I now need to be able to mine rocks or stone. I am using the standard FPS controller and a child axe for the player so what I want when I left click is the axe to swing forward and then back and the rock to loose some health. I also want the rock to take damage only when the player is right next to it as there will be many of these rocks around. So the script needs to work with multiple rocks. Does anyone know a solution?

  • Liked by
Reply
1 on July 29, 2018

Is your axe going to actually hit the stone, and so you can use collisions to trigger events…? or will it be more like Minecraft where it just pretends to hit it and you can be a range of distances away?

on August 10, 2018

Thanks for replying…I haven’t really decided yet. I think if the axe can actually hit the stone that would be better for the style of game. Do you know how this could work?

Show more replies
  • Liked by
Reply
Cancel
2 on August 22, 2018

Can someone please reply?

 

Wise
on August 22, 2018

Raycast forward from the camera to get the rock you’re hitting.

Subtract 1 from the rocks health as fast as you want the player to mine.

Destroy the rock when health is <= 0

 

on August 26, 2018

Thanks, I’ll give it a try

 

 

Show more replies
  • Liked by
Reply
Cancel