Created
February 10, 2018 00:55
-
-
Save oismaelash/486a809a1f76a6c10067421a338cffd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
/// <summary> | |
/// Link de referencia para estudo: | |
/// https://unity3d.com/pt/learn/tutorials/topics/2d-game-creation/2d-physics-overview?playlist=17120 | |
/// </summary> | |
public class MyCharacterManager : MonoBehaviour | |
{ | |
[SerializeField] private float velocityMyCharacter = 1; | |
private void Update() | |
{ | |
if (Input.GetKey(KeyCode.LeftArrow)) | |
{ | |
transform.Translate(Vector3.left * velocityMyCharacter * Time.deltaTime); | |
} | |
if (Input.GetKey(KeyCode.RightArrow)) | |
{ | |
transform.Translate(Vector3.right * velocityMyCharacter * Time.deltaTime); | |
} | |
} | |
#region IsTrigger = false | |
private void OnCollisionEnter2D(Collision2D collision) | |
{ | |
if (collision.gameObject.CompareTag("Finish")) | |
{ | |
print("Colidiu com a parede"); | |
print("nome da parede:: " + collision.gameObject.name); | |
} | |
} | |
private void OnCollisionStay2D(Collision2D collision) | |
{ | |
if (collision.gameObject.CompareTag("Finish")) | |
{ | |
print("Esta colidindo com a parede de colidir com a parede"); | |
} | |
} | |
private void OnCollisionExit2D(Collision2D collision) | |
{ | |
if (collision.gameObject.CompareTag("Finish")) | |
{ | |
print("Parou de colidir com a parede"); | |
print("nome da parede:: " + collision.gameObject.name); | |
} | |
} | |
#endregion | |
#region IsTrigger = true | |
private void OnTriggerEnter2D(Collider2D collision) | |
{ | |
if (collision.gameObject.CompareTag("Finish")) | |
{ | |
print("Atravesou a parede com a parede"); | |
print("nome da parede:: " + collision.gameObject.name); | |
} | |
} | |
private void OnTriggerStay2D(Collider2D collision) | |
{ | |
if (collision.gameObject.CompareTag("Finish")) | |
{ | |
print("Esta dentro da parede"); | |
} | |
} | |
private void OnTriggerExit2D(Collider2D collision) | |
{ | |
if (collision.gameObject.CompareTag("Finish")) | |
{ | |
print("Saiu de dentro da parede"); | |
} | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment