Point fire point at the current center of Camera If (Input.GetKeyDown(Ke圜ode.R) & canFire) If (Input.GetMouseButton(0) & !singleFire) If (Input.GetMouseButtonDown(0) & singleFire) Public float weaponDamage = 15 //How much damage should this weapon dealīulletsPerMagazineDefault = bulletsPerMagazine
REALISTIC FPS PREFAB EMERALD AI CODE
Create a new script, name it "SC_Weapon" and paste the code below inside it:.Select secondary weapon when pressing 1 At the start we enable the primary weapon and disable the secondary
REALISTIC FPS PREFAB EMERALD AI UPDATE
Start is called before the first frame update Public class SC_WeaponManager : MonoBehaviour Create a new script, name it "SC_WeaponManager" and paste the code below inside it:.The player weapon system will consist of 3 components: a Weapon manager, a Weapon script, and a Bullet script. Assign the Main Camera to the Player Camera variable in SC_CharacterController.Attach SC_CharacterController script to "Player" Object (You will notice that it also added another component called Character Controller, change its center value to (0, 1, 0)).Rotation.x = Mathf.Clamp(rotation.x, -lookXLimit, lookXLimit) Rotation.x += -Input.GetAxis("Mouse Y") * lookSpeed Rotation.y += Input.GetAxis("Mouse X") * lookSpeed MoveDirection.y -= gravity * ltaTime ĬharacterController.Move(moveDirection * ltaTime) This is because gravity should be applied when the moveDirection is multiplied by deltaTime). Gravity is multiplied by deltaTime twice (once here, and once below MoveDirection = (forward * curSpeedX) + (right * curSpeedY) Vector3 right = transform.TransformDirection(Vector3.right) įloat curSpeedX = canMove ? speed * Input.GetAxis("Vertical") : 0 įloat curSpeedY = canMove ? speed * Input.GetAxis("Horizontal") : 0 Vector3 forward = transform.TransformDirection(Vector3.forward) We are grounded, so recalculate move direction based on axes Public class SC_CharacterController : MonoBehaviour SC_CharacterController.cs using UnityEngine Create a new script, name it "SC_CharacterController" and paste the code below inside it:.Move the Main Camera inside "Player" Object and change its position to (0, 1.64, 0).Remove Capsule Collider component from Capsule and change its position to (0, 1, 0).Create new Capsule (Game Object -> 3D Object -> Capsule) and move it inside "Player" Object.Create a new Game Object (Game Object -> Create Empty) and name it "Player".Here we will create a controller that will be used by our player. To make an FPS game in Unity we will need a player controller, an array of items (weapons in this case), and the enemies. UI Menu (Main Menu, Pause Menu, Load Menu.First-Person Shooter (FPS) is a sub-genre of shooter games where the player is controlled from a first-person perspective.Jumpscares (Animation, Scare Effects, Scared Breath, Customizable).Scene Preloader (Background Change, Tips).Zombie AI (Sleep, Wander, Scream, Agony, Hunger, Attack, Attract, Footsteps).Rebindable Keyboard Controls at Runtime.More Objects (Keypad Lock, Keycard Lock, Padlock).Types (Mouse, Animation, Locked, Jammed).Door, Drawer, Lever, Valve, Movable Interact.Light Items (Flashlight, Hinge Lantern, Candle).Drag Rigidbody System (Rotate, Zoom, Throw).Examination System (Rotate, Double Examine, Papers).Objectives System (Add, Complete, Complete and Add, Events).Inventory System (Add, Remove, Move, Use, Drop, Examine, Store, Shortcuts).Advanced Menu System (Cross-Platform Support).Save/Load System (Player Data, Scene Data, Inventory, Encryption).Player Controller (Walk, Run, Jump, Crouch, Prone, Ladder Climbing).It contains a lot of ready-to-use assets, just drag and drop them into a scene. HFPS KIT is an advanced and easy-to-use horror game template with many features essential to creating your own horror game, including gameplay features seen in AAA horror games of the last decade.