Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ENEMY STATE (FREEFALL)
- public override void Coll_Collision(Collision2D collision) // *OnCollisionEnter2D
- {
- if (collision.gameObject.tag == "HITBOX_WALL")
- {
- wall_hits++;
- Hitbox_Wall wall = enemy.get_hitbox_wall_data();
- // ISSUE BELOW ///
- // When it hits the wall, calculate speed and apply velocity.
- Vector2 impact_velocity = -collision.relativeVelocity; // Get the enemy's impact velocity from the wall
- float impact_speed = impact_velocity.sqrMagnitude;
- Debug.Log(impact_speed);
- // If the speed at which the enemy hits the player is
- if (impact_speed > wall.wall_damagable_speed)
- {
- wall.DealDamage();
- }
- // Apply velocity from the ground
- enemy.get_rigidBody2D().velocity = impact_velocity * wall.elasticity * wall.coldir;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement