public void shouldNotLandWhenAlreadGrounded() { string[] colliders = { "one", "two", "three" }; bool shouldLandEvent = CharacterControllerLogic.shouldLandEvent(colliders, true, "four"); Assert.AreEqual(shouldLandEvent, false); }
public void shouldLandWhenColliderNotSelf() { string[] colliders = { "one", "two", "three" }; bool shouldLandEvent = CharacterControllerLogic.shouldLandEvent(colliders, false, "four"); Assert.AreEqual(shouldLandEvent, true); }
private void FixedUpdate() { // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground // This can be done using layers instead but Sample Assets will not overwrite your project settings. Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround); var cNames = colliders.Select(col => col.gameObject.name).ToArray(); if (CharacterControllerLogic.shouldLandEvent(cNames, m_Grounded, gameObject.name)) { OnLandEvent.Invoke(); m_Grounded = true; } }