Commit d074bf89 authored by Markus Schlösser's avatar Markus Schlösser
Browse files

Cannons can now shoot through enviroment

parent 3629c83f
......@@ -103,10 +103,12 @@ MonoBehaviour:
cannonBarrel: {fileID: 1682295116660206}
fire: {fileID: 1087194835788670, guid: 3fd0675fac3d4794aafbb72c8557c635, type: 2}
fireDelay: 1
phase: 0
speed: 7
anim: {fileID: 95962382210488100}
animRadVorne: {fileID: 0}
animRadHinten: {fileID: 0}
ignoreEnviroment: 1
--- !u!212 &212468767237705114
SpriteRenderer:
m_ObjectHideFlags: 1
......
......@@ -9,6 +9,7 @@ public class CannonController : MonoBehaviour, IResetable {
[SerializeField] private Animator anim;
[SerializeField] private Animator animRadVorne;
[SerializeField] private Animator animRadHinten;
[SerializeField] private bool ignoreEnviroment;
private Coroutine co;
......@@ -36,6 +37,7 @@ public class CannonController : MonoBehaviour, IResetable {
obj.transform.localScale = transform.lossyScale;
// Flugrichtung
obj.GetComponent<Rigidbody2D>().velocity = cannonBarrel.transform.right * speed;
obj.GetComponent<ProjektilController>().ignoreEnviroment = ignoreEnviroment;
}
public void ResetToLevelBegin() {
......
......@@ -2,6 +2,8 @@
public class ProjektilController : MonoBehaviour, IResetable {
public bool ignoreEnviroment;
private const float MAX_LIFETIME = 15.0f;
private float lifetime;
......@@ -15,6 +17,9 @@ public class ProjektilController : MonoBehaviour, IResetable {
}
private void OnTriggerEnter2D(Collider2D other) {
// Don't destroy on contact with enviroment if set to ignore
if (other.gameObject.layer == 12 && ignoreEnviroment) return;
Destroy(gameObject);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment