neroitaly.blogg.se

Shooting blocks unity
Shooting blocks unity












shooting blocks unity

Name the first one “Player” and name the second one “Bullet.” Navigate to the Project folder and create a new folder and name it “Scripts.” Open the Scripts folder once you have created it, and create two C# scripts. We can create the logic for shooting bullets in a C# script. In this lesson we will begin working on the logic for shooting bullets from the gun we created in the previous lesson. Use the color picker to choose a light blue color:ĭrag and drop the Gun material onto the Gun. We can now make a material for our gun so in the Materials folder right click>Create>Material. You can disable the Shadow Casting by selecting both Cubes and then on the Mesh Renderer component in the Inspector, change the Cast Shadows option to Off. If you hit the Play button in the editor and test the changes, you see the gun move with the Player: We can now move the Cube(1) a little closer to the handle of the Gun, so make Cube(1) 0.65 on the Z axis, and make the Y value be 0.1: We need to adjust the Scale of the Cube object to 0.3 on the X axis, 0.5 on the Y axis, and 0.3 on the Z axis.ĭuplicate the Cube and re-position it so its at 0 on the X axis 5.96046 on the Y axis, and 1 on the Z axis.Īdjust the Scale to 0.3 on the X, 0.3 on the Y, and 1 on the Z. You can remove a component by clicking on the cog icon in the upper right hand corner of the component and choosing Remove Component. Select the Cube in the Hierarchy and remove the Box Collider component from it in the Inspector window. What we now need to do is take the Cube object and make that a child to the Gun: The Gun’s position is relative to the FirstPersonCharcter object because its a child to the FirstPersonCharcter object. With the FirstPersonCharacter selected in the Hierarchy create an empty game object, and rename this to “Gun.” This cube will follow the Player around wherever they are looking, and by doing this we can now make the Player have a weapon. We need to rename the FPSController to “Player.”Ĭreate a Cube and make sure the Cube is a child to the FirstPersonCharacter in the Hierarchy: The weapon will be something that belongs to the Player and the Player in our game currently is the FPSController. This will make these object a child of the GameController. Select the Directional Light, Floor, and FPSController in the Hierarchy and drag and drop them into the GameController object. We will now work on creating the weapon that the Player will use to shoot enemies with.Ĭreate an empty game object and rename it to “GameController.”

shooting blocks unity

We can create a new folder called “Scenes” inside the Project folder and move the Level1 Scene file into the Scenes folder. Save the Scene as “Level1” and you will see that we now have a Unity Scene file in the root of the Assets folder. Its important to save your Scene often so that you do not lose any progress with the work that you have done. In order to save a Scene in Unity you can either to it by using the Ctrl + S keys on the keyboard or by clicking on File>Save Scenes in the Unity editor.














Shooting blocks unity