protected virtual void Start() { m_smartCollider = GetComponent <SmartPlatformCollider>(); m_smartCollider.OnSideCollision += OnSideCollision; m_savedOneWayCollisionDown = m_smartCollider.OneWayCollisionDown; m_prevPos = transform.position; // Automatically remove OneWayCollisionDown from layer collision in case user forgot to do that. // This allow player to move through OneWayCollisionDown ( or pass through) colliders in any direction but down. m_smartCollider.LayerCollision = m_smartCollider.LayerCollision & ~m_smartCollider.OneWayCollisionDown; // Same with climbing layers m_smartCollider.LayerCollision = m_smartCollider.LayerCollision & ~ClimbingLayers; }
// Use this for initialization void Start() { m_rigidBody2D = GetComponent <Rigidbody2D>(); m_spriteRenderer = GetComponent <SpriteRenderer>(); m_animator = GetComponent <Animator>(); m_smartRectCollider = GetComponent <SmartPlatformCollider>(); m_smartRectCollider.OnCollision += _OnSmartCollision; m_smartRectCollider.OnSideCollision += _OnSideCollision; m_walkingDrag = m_rigidBody2D.drag; VPad.Start(); // Add an offset to horizontal raycasts to avoid missing collisions with lateral moving platforms m_smartRectCollider.SkinRightOff01 = 0.1f; m_smartRectCollider.SkinLeftOff01 = 0.1f; OnStateChanged += _OnStateChanged; SetNextState(eState.Idle); }
// Use this for initialization void Start() { m_rigidBody2D = GetComponent <Rigidbody2D>(); if (m_spriteRenderer == null) { m_spriteRenderer = GetComponent <SpriteRenderer>(); } m_animator = GetComponent <Animator>(); m_smartRectCollider = GetComponent <SmartPlatformCollider>(); m_player = GetComponent <Player>(); m_walkingDrag = m_rigidBody2D.drag; // Add an offset to horizontal raycasts to avoid missing collisions with lateral moving platforms m_smartRectCollider.SkinRightOff01 = 0.1f; m_smartRectCollider.SkinLeftOff01 = 0.1f; OnStateChanged += _OnStateChanged; SetNextState(eState.Idle); m_GameManager = GameManager.Instance; }