Bonjour/Bonsoir à tous.

Voilà plusieurs jours, que je bloque sur un problème et je me suis décidé à demander votre aide.

Soit, mon projet est un platformer 2D sous Unity dans lequel on peut tirer avec une arme a feu à l'aide de la souris. Mon problème est que la collision de mon tir ne semble pas influer sur les collisions de mes autres objets :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
private void Shoot ()
	{
		Vector3 mousePositionWorld = Camera.main.ScreenToWorldPoint (Input.mousePosition);
 
		Vector2 mousePosition = new Vector2 (mousePositionWorld.x, mousePositionWorld.y);
 
		Vector2 firePointPosition = new Vector2 (firePoint.position.x, firePoint.position.y);
 
		RaycastHit2D hit = Physics2D.Raycast (firePointPosition, mousePosition - firePointPosition, Mathf.Infinity, NotToHit);
 
 
 
		Debug.DrawLine(firePointPosition, (mousePosition - firePointPosition)* 100);
 
		if (hit.collider != null)
 
		{
 
			Debug.DrawLine (firePointPosition, hit.point, Color.red);
 
			if (hit.collider.tag == "enemy")
			{
				Debug.Log ("TOUCHE");
				Debug.DrawLine (firePointPosition, hit.point, Color.cyan);
				EnemyFoght enemy = hit.collider.GetComponent<EnemyFoght> ();
				player.Attack (enemy);
			} 
			}
				Effect();
		}
Et il ne se passe rien etje dois avouer que je sèche complètement. :/

(ici le code complet : )
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class BOOM : MonoBehaviour 
{
 
	[SerializeField]
	private float fireRate = 0;
 
	[SerializeField]
	private float Damage = 250f;
 
	[SerializeField]
	private LayerMask NotToHit;
 
	private float timeToFire = 0; 
 
	private Transform firePoint;
 
	[SerializeField]
	private Transform BulletTrailPrefab;
 
	[SerializeField]
	private Transform FlashPrefab;
 
	private Player player;
 
	private void Awake()
	{
		firePoint = transform.GetChild(0);
 
		if (firePoint == null)
		{
			Debug.Log ("PLEASE");
		}
	}
 
	private void Start()
	{
		player = GameManager.Instance.playerinstantiate.GetComponent<Player>();
	}
 
	void Update () 
	{
		if (fireRate == 0) 
		{
			if (Input.GetMouseButton (0)) 
			{
				Shoot ();
			}
		} else if (Input.GetMouseButton (0) && Time.time > timeToFire) 
		{
			timeToFire = Time.time + 1 / fireRate;
			Shoot();
		}
 
 
	}
 
	private void Shoot ()
	{
		Vector3 mousePositionWorld = Camera.main.ScreenToWorldPoint (Input.mousePosition);
 
		Vector2 mousePosition = new Vector2 (mousePositionWorld.x, mousePositionWorld.y);
 
		Vector2 firePointPosition = new Vector2 (firePoint.position.x, firePoint.position.y);
 
		RaycastHit2D hit = Physics2D.Raycast (firePointPosition, mousePosition - firePointPosition, Mathf.Infinity, NotToHit);
 
 
 
		Debug.DrawLine(firePointPosition, (mousePosition - firePointPosition)* 100);
 
		if (hit.collider != null)
 
		{
 
			Debug.DrawLine (firePointPosition, hit.point, Color.red);
 
			if (hit.collider.tag == "enemy")
			{
				Debug.Log ("TOUCHE");
				Debug.DrawLine (firePointPosition, hit.point, Color.cyan);
				EnemyFoght enemy = hit.collider.GetComponent<EnemyFoght> ();
				player.Attack (enemy);
			} 
			}
				Effect();
		}
 
 
 
 
	private void Effect()
	{
		Instantiate (BulletTrailPrefab, firePoint.position, firePoint.rotation);
 
		Transform Flash = Instantiate (FlashPrefab, firePoint.position, firePoint.rotation) as Transform;
 
		float size = Random.Range (0.6f, 0.9f);
 
		Flash.localScale = new Vector3 (size, size, size);
		Destroy (Flash.gameObject, 0.2f);
	}
 
 
 
 
 
}


(Ainsi que le script "EnemyFoght" appelé dans le script: )
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class EnemyFoght : EnnemiStats {
 
 
	public bool isAlive { get { return PV > 0f; } }
 
 
	public void RecevoirDegat(float Degat)
	{
		PV -= Degat;
 
		if (!isAlive)
		{
			Destroy (gameObject);
		}
 
		Debug.Log ("Coucou");
	}
 
 
}


Voilà, Merci d'avance à ceux qui me donneront un peu de leurs temps et une très bonne journée/soirée à vous !