- Home /
How to implement the melee attack like in Muck?
Hello! I recently watched Dani's Muck video and noticed he implemented the melee attack in an interesting way. In video 11:22 , he is picking a stone. If you set the speed to 0.25 you will clearly see the pick isn't really colliding with the stone. It's more like an animated UI that is on top of everything. How can I realize this effect?
Answer by Klarzahs · Aug 22, 2021 at 11:03 AM
Hi @dongminghui1313
I'd do it by raycasting from the top center of your weapon (pickaxe) into your look direction. If the ray hits something "in range", make an animated sprite visible at that position and animate it. You can place the sprite either in 3D space or map the hit coordinate back into Screenspace, so 2D.
Hope this helps
Answer by AaronBacon · Aug 22, 2021 at 11:49 AM
I think you're referring to a Depth Only camera, which basically renders what it sees On top of the main camera. So if you set up a camera like this:
⠀
⠀
It'll render like an overlay to the main camera (It renders what would usually be the skybox as transparent).
⠀
The main way to set up something like muck is to use Culling masks to make the "Arms" camera unable to see anything except your own arms/Tools.
⠀
⠀
Then do the opposite for the main camera, only excluding your arms, and you should get an effect like in the video, since the Arms are being rendered separately and thus cannot be blocked by collisions with objects.
⠀
If you want to learn more there's loads of videos out there on camera stacking: https://www.youtube.com/watch?v=l8k88iZWcB8
Answer by dongminghui1313 · Aug 22, 2021 at 03:47 PM
Thank you both! @AaronBacon @Klarzahs I think by combining raycast and overlay camera I can achieve what I want!
Your answer

Follow this Question
Related Questions
How to get 3d Melee attack animation to play right? 0 Answers
GUI Follow RaycastHit 2 Answers
How to make a 3d object act like GUI? 1 Answer
Damage script not working? 1 Answer
Football penalty game- Move gameobject in direction of swipe with force 0 Answers