Fixed drilling, touchingdirections and ruleTile tiles
ruleTile tiles were not all from the correct tileSet (some were from the example tileSet)
changed player collision detection to continious
| | |
| | | propertyPath: m_Name |
| | | value: Player |
| | | objectReference: {fileID: 0} |
| | | - target: {fileID: 3884295854780712968, guid: c220ec455fce341408d66d880b464cad, type: 3} |
| | | propertyPath: m_Size.x |
| | | value: 0.7 |
| | | objectReference: {fileID: 0} |
| | | - target: {fileID: 3884295854780712968, guid: c220ec455fce341408d66d880b464cad, type: 3} |
| | | propertyPath: m_Size.y |
| | | value: 0.7 |
| | | objectReference: {fileID: 0} |
| | | - target: {fileID: 3884295854780712968, guid: c220ec455fce341408d66d880b464cad, type: 3} |
| | | propertyPath: m_EdgeRadius |
| | | value: 0 |
| | | objectReference: {fileID: 0} |
| | | - target: {fileID: 4941032555966952991, guid: c220ec455fce341408d66d880b464cad, type: 3} |
| | | propertyPath: m_CollisionDetection |
| | | value: 1 |
| | | objectReference: {fileID: 0} |
| | | - target: {fileID: 5338311196462064651, guid: c220ec455fce341408d66d880b464cad, type: 3} |
| | | propertyPath: wallDistance |
| | | value: 0.02 |
| | | objectReference: {fileID: 0} |
| | | - target: {fileID: 5338311196462064651, guid: c220ec455fce341408d66d880b464cad, type: 3} |
| | | propertyPath: groundDistance |
| | | value: 0.02 |
| | | objectReference: {fileID: 0} |
| | | m_RemovedComponents: [] |
| | | m_RemovedGameObjects: [] |
| | | m_AddedGameObjects: [] |
| | |
| | | { |
| | | get |
| | | { |
| | | return animator.GetBool(AnimationStrings.canMove) && !PauseMenu.GameIsPaused; |
| | | return animator.GetBool(AnimationStrings.canMove) && !PauseMenu.GameIsPaused && !IsDrilling; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | private void FixedUpdate() |
| | | { |
| | | if (moveInput.y == 0) |
| | | if (CanMove) |
| | | { |
| | | if (rb.velocity.y <= maxFallSpeed) |
| | | if (moveInput.y == 0) |
| | | { |
| | | // max fall speed, dont accelerate more |
| | | rb.velocity = new Vector2(moveInput.x * moveSpeed, maxFallSpeed); |
| | | if (rb.velocity.y <= maxFallSpeed) |
| | | { |
| | | // max fall speed, dont accelerate more |
| | | rb.velocity = new Vector2(moveInput.x * moveSpeed, maxFallSpeed); |
| | | } |
| | | else |
| | | { |
| | | // normal fall |
| | | rb.velocity = new Vector2(moveInput.x * moveSpeed, rb.velocity.y); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // normal fall |
| | | rb.velocity = new Vector2(moveInput.x * moveSpeed, rb.velocity.y); |
| | | if (rb.velocity.y < 0 && moveInput.y > 0) |
| | | { |
| | | // falling but moving upwards |
| | | rb.velocity = new Vector2(moveInput.x * moveSpeed, (moveInput.y * moveSpeed) + rb.velocity.y); |
| | | } |
| | | else |
| | | { |
| | | // moving upwards no falling |
| | | rb.velocity = new Vector2(moveInput.x * moveSpeed, (moveInput.y * moveSpeed)); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (rb.velocity.y < 0 && moveInput.y > 0) |
| | | if (touchingDirections.IsGrounded) |
| | | { |
| | | // falling but moving upwards |
| | | rb.velocity = new Vector2(moveInput.x * moveSpeed, (moveInput.y * moveSpeed) + rb.velocity.y); |
| | | if (maxFallSpeedCurrent < maxFallSpeedDamge) |
| | | { |
| | | TakeFallDamage(Math.Abs((int)maxFallSpeedCurrent)); |
| | | maxFallSpeedCurrent = 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // moving upwards no falling |
| | | rb.velocity = new Vector2(moveInput.x * moveSpeed, (moveInput.y * moveSpeed)); |
| | | } |
| | | } |
| | | if (touchingDirections.IsGrounded) |
| | | { |
| | | if (maxFallSpeedCurrent < maxFallSpeedDamge) |
| | | { |
| | | TakeFallDamage(Math.Abs((int)maxFallSpeedCurrent)); |
| | | maxFallSpeedCurrent = 0; |
| | | } |
| | | } |
| | | else if (IsFlying) |
| | | { |
| | | maxFallSpeedCurrent = rb.velocity.y; |
| | | } |
| | | else |
| | | { |
| | | if (maxFallSpeedCurrent > rb.velocity.y) |
| | | else if (IsFlying) |
| | | { |
| | | maxFallSpeedCurrent = rb.velocity.y; |
| | | } |
| | | } |
| | | if (touchingDirections.IsGrounded && moveInput.y < 0 && !IsDrilling) |
| | | { |
| | | //IsDrilling = true; |
| | | Drill(DrillDirection.Down); |
| | | } |
| | | if (touchingDirections.IsGrounded && touchingDirections.IsAtWall && moveInput.x != 0 && !IsDrilling) |
| | | { |
| | | //IsDrilling = true; |
| | | if (touchingDirections.IsAtWallLeft) |
| | | else |
| | | { |
| | | Drill(DrillDirection.Left); |
| | | if (maxFallSpeedCurrent > rb.velocity.y) |
| | | { |
| | | maxFallSpeedCurrent = rb.velocity.y; |
| | | } |
| | | } |
| | | else if (touchingDirections.IsAtWallRight) |
| | | if (touchingDirections.IsGrounded && moveInput.y < 0 && !IsDrilling) |
| | | { |
| | | Drill(DrillDirection.Right); |
| | | //IsDrilling = true; |
| | | Drill(DrillDirection.Down); |
| | | } |
| | | |
| | | if (touchingDirections.IsGrounded && moveInput.x != 0 && !IsDrilling) |
| | | { |
| | | if (touchingDirections.IsAtWallLeft && moveInput.x < 0) |
| | | { |
| | | Drill(DrillDirection.Left); |
| | | } |
| | | else if (touchingDirections.IsAtWallRight && moveInput.x > 0) |
| | | { |
| | | Drill(DrillDirection.Right); |
| | | } |
| | | } |
| | | } |
| | | if (IsDrilling) |
| | | { |
| | | rb.velocity = Vector2.zero; |
| | | if (timeSinceDrill > drillingTime) |
| | | { |
| | | IsDrilling = false; |
| | |
| | | |
| | | public void OnMove(InputAction.CallbackContext context) |
| | | { |
| | | if (CanMove) |
| | | { |
| | | moveInput = context.ReadValue<Vector2>(); |
| | | moveInput = context.ReadValue<Vector2>(); |
| | | |
| | | IsMoving = moveInput.x != 0; |
| | | IsMoving = moveInput.x != 0; |
| | | |
| | | IsFlying = (moveInput.y != 0); |
| | | IsFlying = (moveInput.y != 0); |
| | | |
| | | SetFacingDirection(moveInput); |
| | | |
| | | } |
| | | else |
| | | SetFacingDirection(moveInput); |
| | | if (IsDrilling) |
| | | { |
| | | IsMoving = false; |
| | | IsFlying = false; |
| | | moveInput = Vector2.zero; |
| | | //moveInput = Vector2.zero; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | IsDrilling = true; |
| | | ContactPoint2D[] contactPoints = new ContactPoint2D[1]; |
| | | Debug.Log("drillDirection: " + drillDirection.ToString()); |
| | | //rb.GetContacts(contactPoints); |
| | | if (drillDirection == DrillDirection.Down) |
| | | switch (drillDirection) |
| | | { |
| | | touchingDirections.groundHits[0].collider.GetContacts(contactPoints); |
| | | } else if (drillDirection == DrillDirection.Left || drillDirection == DrillDirection.Right) |
| | | { |
| | | touchingDirections.wallHits[0].collider.GetContacts(contactPoints); |
| | | case DrillDirection.Left: |
| | | touchingDirections.wallHitsLeft[0].collider.GetContacts(contactPoints); |
| | | break; |
| | | case DrillDirection.Right: |
| | | touchingDirections.wallHitsRight[0].collider.GetContacts(contactPoints); |
| | | break; |
| | | case DrillDirection.Down: |
| | | touchingDirections.groundHits[0].collider.GetContacts(contactPoints); |
| | | break; |
| | | } |
| | | CharacterEvents.characterDrill.Invoke(contactPoints[0], drillDirection); |
| | | } |
| | |
| | | public class TouchingDirections : MonoBehaviour |
| | | { |
| | | public ContactFilter2D castFilter; |
| | | public float groundDistance = 0.05f; |
| | | public float wallDistance = 0.2f; |
| | | public float groundDistance = 0.01f; |
| | | public float wallDistance = 0.01f; |
| | | public float ceilingDistance = 0.05f; |
| | | |
| | | //private Vector2 wallCheckDirection => gameObject.transform.localScale.x > 0 ? Vector2.right : Vector2.left; |
| | |
| | | public GameObject rotorGO; |
| | | |
| | | BoxCollider2D touchingCol; |
| | | //CapsuleCollider2D touchingCol; |
| | | Animator animator; |
| | | Animator animator_rotor; |
| | | |
| | | public RaycastHit2D[] groundHits = new RaycastHit2D[5]; |
| | | public RaycastHit2D[] wallHits = new RaycastHit2D[5]; |
| | | public RaycastHit2D[] wallHitsRight = new RaycastHit2D[5]; |
| | | public RaycastHit2D[] wallHitsLeft = new RaycastHit2D[5]; |
| | | public RaycastHit2D[] ceilingHits = new RaycastHit2D[5]; |
| | | |
| | | [SerializeField] |
| | |
| | | { |
| | | rb = GetComponent<Rigidbody2D>(); |
| | | touchingCol = rb.GetComponent<BoxCollider2D>(); |
| | | //touchingCol = rb.GetComponent<CapsuleCollider2D>(); |
| | | animator = rb.GetComponent<Animator>(); |
| | | animator_rotor = rotorGO.GetComponent<Animator>(); |
| | | } |
| | |
| | | |
| | | void FixedUpdate() |
| | | { |
| | | |
| | | //int contactsAmount = touchingCol.GetContacts(contacts); |
| | | //Debug.Log("contactsAmount: " + contactsAmount); |
| | | IsGrounded = touchingCol.Cast(Vector2.down, castFilter, groundHits, groundDistance) > 0; |
| | | IsAtWallLeft = touchingCol.Cast(Vector2.left, castFilter, wallHits, wallDistance) > 0; |
| | | IsAtWallRight = touchingCol.Cast(Vector2.right, castFilter, wallHits, wallDistance) > 0; |
| | | IsAtWallLeft = touchingCol.Cast(Vector2.left, castFilter, wallHitsLeft, wallDistance) > 0; |
| | | IsAtWallRight = touchingCol.Cast(Vector2.right, castFilter, wallHitsRight, wallDistance) > 0; |
| | | IsAtCeiling = touchingCol.Cast(Vector2.up, castFilter, ceilingHits, ceilingDistance) > 0; |
| | | } |
| | | |
| | |
| | | - m_Id: 8 |
| | | m_Sprites: |
| | | - {fileID: 68800321, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3} |
| | | - {fileID: 1328409926, guid: 2dece116af0ca9145ae459928df1a55f, type: 3} |
| | | - {fileID: 1862643484, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3} |
| | | m_GameObject: {fileID: 0} |
| | | m_MinAnimationSpeed: 1 |
| | | m_MaxAnimationSpeed: 1 |
| | |
| | | - {x: 1, y: 0, z: 0} |
| | | - {x: 0, y: -1, z: 0} |
| | | m_RuleTransform: 0 |
| | | - m_Id: 12 |
| | | m_Sprites: |
| | | - {fileID: -1325585479, guid: 2dece116af0ca9145ae459928df1a55f, type: 3} |
| | | m_GameObject: {fileID: 0} |
| | | m_MinAnimationSpeed: 1 |
| | | m_MaxAnimationSpeed: 1 |
| | | m_PerlinScale: 0.5 |
| | | m_Output: 0 |
| | | m_ColliderType: 1 |
| | | m_RandomTransform: 0 |
| | | m_Neighbors: 0100000001000000020000000100000001000000010000000100000001000000 |
| | | m_NeighborPositions: |
| | | - {x: 0, y: 1, z: 0} |
| | | - {x: 1, y: 0, z: 0} |
| | | - {x: 1, y: 1, z: 0} |
| | | - {x: -1, y: 0, z: 0} |
| | | - {x: 0, y: -1, z: 0} |
| | | - {x: -1, y: 1, z: 0} |
| | | - {x: -1, y: -1, z: 0} |
| | | - {x: 1, y: -1, z: 0} |
| | | m_RuleTransform: 0 |
| | | - m_Id: 13 |
| | | m_Sprites: |
| | | - {fileID: 1290617244, guid: 2dece116af0ca9145ae459928df1a55f, type: 3} |
| | | - {fileID: 956194596, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3} |
| | | m_GameObject: {fileID: 0} |
| | | m_MinAnimationSpeed: 1 |
| | | m_MaxAnimationSpeed: 1 |
| | |
| | | - {x: -1, y: 1, z: 0} |
| | | - {x: 1, y: 1, z: 0} |
| | | m_RuleTransform: 0 |
| | | - m_Id: 16 |
| | | m_Sprites: |
| | | - {fileID: -855959738, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3} |
| | | m_GameObject: {fileID: 0} |
| | | m_MinAnimationSpeed: 1 |
| | | m_MaxAnimationSpeed: 1 |
| | | m_PerlinScale: 0.5 |
| | | m_Output: 0 |
| | | m_ColliderType: 1 |
| | | m_RandomTransform: 0 |
| | | m_Neighbors: 0100000001000000010000000100000001000000010000000200000001000000 |
| | | m_NeighborPositions: |
| | | - {x: 0, y: 1, z: 0} |
| | | - {x: 1, y: 0, z: 0} |
| | | - {x: -1, y: 0, z: 0} |
| | | - {x: 0, y: -1, z: 0} |
| | | - {x: -1, y: -1, z: 0} |
| | | - {x: 1, y: -1, z: 0} |
| | | - {x: 1, y: 1, z: 0} |
| | | - {x: -1, y: 1, z: 0} |
| | | m_RuleTransform: 0 |
| | | - m_Id: 14 |
| | | m_Sprites: |
| | | - {fileID: 1623399786, guid: 2dece116af0ca9145ae459928df1a55f, type: 3} |
| | | - {fileID: 1598334396, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3} |
| | | m_GameObject: {fileID: 0} |
| | | m_MinAnimationSpeed: 1 |
| | | m_MaxAnimationSpeed: 1 |
| | |
| | | m_RuleTransform: 0 |
| | | - m_Id: 15 |
| | | m_Sprites: |
| | | - {fileID: -889089113, guid: 2dece116af0ca9145ae459928df1a55f, type: 3} |
| | | - {fileID: 1451081626, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3} |
| | | m_GameObject: {fileID: 0} |
| | | m_MinAnimationSpeed: 1 |
| | | m_MaxAnimationSpeed: 1 |
| | |
| | | Generate Tilemap in GameManger with loading screen? |
| | | Tilemap seed |
| | | Save/Load tilemaps |
| | | maybe save all deleted tiles in an array and destroy them on load? (maybe better than saving all tiles in savefile) |
| | | |