Quantcast
Channel: Questions in topic: "ignorecollision"
Viewing all articles
Browse latest Browse all 148

Player Collider isn't found by Physics2D

$
0
0
I am trying to have a bullet fly out my ship. However, the bullet doesn't move and I think I have the error down to the fact, that it collides with my ship. This is the Firing-Coroutine: IEnumerator FireGun() { GameObject bulletClone = Instantiate(bullet, transform.position, player.GetComponent().rotation); bulletClone.GetComponent().damage = damage; bulletClone.GetComponent().AddForce(bulletClone.transform.up * bulletSpeed); Physics2D.IgnoreLayerCollision(8, 9); Debug.Log(bulletClone.transform.up * bulletSpeed); Debug.Log(bulletClone.GetComponent().velocity); Debug.Log(Physics2D.GetIgnoreLayerCollision(8, 9)); yield return null; } The Player does have the Layer 8, the Bullets do have the Layer 9 and the Log shows those layers get ignored. Log also shows, that a force of 0,500,0 should be applied, but the velocity is 0,0,0. This is the error: ""MissingComponentException: There is no 'Collider' attached to the "Player" game object, but a script is trying to access it. You probably need to add a Collider to the game object "Player". Or your script needs to check if the component is attached before using it."" This is my player: ![alt text][1] It clearly has a collider. Does anybody know what is happening here? Thanks very much in advance Jan [1]: /storage/temp/123668-unbenannt.png

Viewing all articles
Browse latest Browse all 148

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>