UpdateIsGrounded
How do I use Update Is Grounded
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
24 | UpdateIsGrounded(); | 1 |
94 | void UpdateIsGrounded() | 2 |
File name: JumpAndRunMovement.cs
Copy
22 void Update()
23 {
24 UpdateIsGrounded();
25 UpdateIsRunning();
26 UpdateFacingDirection();
27 }
File name: JumpAndRunMovement.cs
Copy
94 void UpdateIsGrounded()
95 {
96 Vector2 position = new Vector2( transform.position.x, transform.position.y );
97
98 RaycastHit2D hit = Physics2D.Raycast( position, -Vector2.up, 0.1f, 1 << LayerMask.NameToLayer( "Ground" ) );
99
100 m_IsGrounded = hit.collider != null;
101 m_Animator.SetBool( "IsGrounded", m_IsGrounded );
102 }
UpdateIsGrounded 141 lượt xem
Gõ tìm kiếm nhanh...