Scripts won't run properly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By shiba117

Hi everybody, so I was working on my game (space invader type) and I decided to make my player and enemy bigger. I was just messing around with the sizes in 2D without touching my scripts and I saved and ran the project to test the new sizes. The script started to work odd, for example if my player would shoot he’d dissappear, also if the enemy would shoot he’d climb a bit up the Y axis,

:bust_in_silhouette: Reply From: jgodfrey

That’s not much to go on to provide help, but… If I had to guess, it sounds like the larger player and enemies may be causing their shots to detect a collision with themselves, which may be causing some unexpected results.

I’d look at how are you setting the shot spawn point for each character and verify that it’s not starting inside the character bounds.

If that is the issue, you could likely fix it by either:

  • Moving the shot spawn point outside the collision bounds — or —
  • Properly setting up the collision masks - so that a players shot cannot collide with the player (and the same for the enemies).