mirror of
https://github.com/ConjureETS/Labo_2_Equ_1_a15.git
synced 2026-03-24 01:50:58 +00:00
fix de missile
This commit is contained in:
parent
9e679ed0af
commit
2bfff5b899
@ -3,7 +3,9 @@ using System.Collections;
|
|||||||
|
|
||||||
public class MissileTravel : MonoBehaviour {
|
public class MissileTravel : MonoBehaviour {
|
||||||
public float missileSpeed;
|
public float missileSpeed;
|
||||||
|
public float range;
|
||||||
private Transform missilePos;
|
private Transform missilePos;
|
||||||
|
private float startingPosX;
|
||||||
private bool inContact = false;
|
private bool inContact = false;
|
||||||
|
|
||||||
// ajouter du damage
|
// ajouter du damage
|
||||||
@ -11,6 +13,7 @@ public class MissileTravel : MonoBehaviour {
|
|||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
this.missilePos = this.transform;
|
this.missilePos = this.transform;
|
||||||
|
this.startingPosX = this.transform.position.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@ -19,6 +22,10 @@ public class MissileTravel : MonoBehaviour {
|
|||||||
{
|
{
|
||||||
this.missilePos.Translate(new Vector3(missileSpeed, 0, 0) * Time.deltaTime);
|
this.missilePos.Translate(new Vector3(missileSpeed, 0, 0) * Time.deltaTime);
|
||||||
}
|
}
|
||||||
|
if (Mathf.Abs(this.startingPosX - this.missilePos.position.x) >= range)
|
||||||
|
{
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCollisionEnter2D(Collision2D other) {
|
void OnCollisionEnter2D(Collision2D other) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -16,7 +16,16 @@ public class ShootingScript : MonoBehaviour {
|
|||||||
print("pewpew");
|
print("pewpew");
|
||||||
nextShootTime = Time.time + attackSpeed;
|
nextShootTime = Time.time + attackSpeed;
|
||||||
//avancer le missile au depart quand il va apparaitre (quand je vais avoir anim de combat)
|
//avancer le missile au depart quand il va apparaitre (quand je vais avoir anim de combat)
|
||||||
GameObject clone = Instantiate( Missile,transform.position,transform.rotation) as GameObject;
|
int valOfLeftOrRight;
|
||||||
|
if (gameObject.transform.rotation.y != 0)
|
||||||
|
{
|
||||||
|
valOfLeftOrRight = -2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
valOfLeftOrRight = 2;
|
||||||
|
}
|
||||||
|
Vector3 missilePos = new Vector3(gameObject.transform.position.x + valOfLeftOrRight, gameObject.transform.position.y, gameObject.transform.position.z);
|
||||||
|
GameObject clone = Instantiate(Missile, missilePos, transform.rotation) as GameObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user