Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Progamming a weapon

I want to make a weapon like the jet vaccum of slime rancher i only know to make the effects using unity´s particles system and shader graphs but i dont know how to make him vaccum the objects and get them to inventory

Best Answer

  • Accepted Answer

    It's more complicated than said. I don't want to scare you but that's a lot of work, but possible! I don't know your skill in coding in unity so I'll just explain most of it.

    First of all, because this is a brackeys forum 😀, here is a brackeys video I would recommend! It shows you how to do raycasts which is important for guns or projectiles . The video will basically tell you how raycast work but here is a short summary. When you create a ray in code, it has a direction and a distance (Also mask layers). This ray can be passed in a function called raycast that takes that ray and does a physics check giving information about the object you shot with the ray. IT'S A VERY USEFUL AND EFFICIENT TOOL!

    Brackeys raycast video -->

    Unity also has a lot of videos and has documentation of raycasting. --> Unity - Scripting API: Physics.Raycast (

    Then from there, you can manipulate the object you shot with logic . You could get the direction of the enemy, or entity, you shot with you slime rancher gun to the guns postion and add a force in that direction you created. It didn't think it will give you the suction feeling like in slime rancher but you are one your way doing that. Basically you can create a box or sphere collider at the end of your gun (set it to trigger so there isn't any real collison but rather sends and event calling the OnTriggerEnter() method) so once the entity hits it, you can trigger some code to send it to an inventory system or die. Whatever you are doing.

    Here is a great video by code monkey on an inventory system I just watched today --> Simple Inventory System in Unity (Store, Use, Stack and Drop Items) - YouTube

    It's for 2D but of course can translate into 3D if you know what you are doing in coding.

    If you are a beginner, I would recommend this course. --> Learn C# Unity Developer 3D Tutorials | |

    If you are an intermediate, I would recommend these courses. 😀

    RPG Combat : Learn Intermediate Unity C# Coding | | GameDev

    RPG Inventory Systems: Intermediate C# Coding |

    Good luck! Send me results if this was helpful to you!

Sign In or Register to comment.