trustedpaster.blogg.se

Unity 3d player movement
Unity 3d player movement






If the player is currently in the run state. Change the players rotation to this new rotation.įunction AudioManagement (shout : boolean) Var newRotation : Quaternion = Quaternion.Lerp(rigidbody.rotation, targetRotation, turnSmoothing * ltaTime) Create a rotation that is an increment closer to the target rotation from the player's rotation. Var targetRotation : Quaternion = Quaternion.LookRotation(targetDirection, Vector3.up) Create a rotation based on this new vector assuming that up is the global y axis. Var targetDirection : Vector3 = new Vector3(horizontal, 0f, vertical)

unity 3d player movement

Create a new vector of the horizontal and vertical inputs. Otherwise set the speed parameter to 0.įunction Rotating (horizontal : float, vertical : float) set the players rotation and set the speed parameter to 5.5f.Īnim.SetFloat(hash.speedFloat, 5.5f, speedDampTime, ltaTime) Set the sneaking parameter to the sneak input.Īnim.SetBool(hash.sneakingBool, sneaking) Var shout : boolean = Input.GetButtonDown("Attract") įunction MovementManagement (horizontal : float, vertical : float, sneaking : boolean) Var sneak : boolean = Input.GetButton("Sneak")

unity 3d player movement

Var v : float = Input.GetAxis("Vertical") Var h : float = Input.GetAxis("Horizontal") Set the weight of the shouting layer to 1. Hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent(HashIDs) Private var hash : HashIDs // Reference to the HashIDs. Private var anim : Animator // Reference to the animator component.

unity 3d player movement

Public var speedDampTime : float = 0.1f // The damping for the speed parameter Public var turnSmoothing : float = 15f // A smoothing value for turning the player. Public var shoutingClip : AudioClip // Audio clip of the player shouting. Unity 3D – Stealth Game – Player Movement – JS Script








Unity 3d player movement