Strange physics, rigidbody, iTween activity

Hey guys, I’m having some strange behaviors with both my projectiles, and my enemies. I’ve been trying to figure this out in the back of my mind, while coding the other aspects, but it’s still eluding me.

Strange behaviors are:

  • Projectiles: sometimes fire straight, and sometimes fire at an angle or slanted, or corkscrew.
  • Enemies getting knocked back using iTween will rotate them in crazy ways, never knocking them directly back, but more knocking them down through the floor usually, etc, even with no rotation code written for them. (I’ve used this code for other games and it’s worked fine with no bugs)
  • Enemies when spawning, sometimes spawn correctly with the particle effect and work fine (maybe 80% of the time), and other times, they rocket straight into the air at high speed and never come down.

The strange thing is, I’ve done games before, I’ve used this same code previously and it’s worked perfectly, this time, the same code has erratic behaviors and renders the game buggy enough to be a serious issue.

If you’ve encountered this before, I’d love some input. Any help would be greatly appreciated.

You can see in the pic attached, that I’m standing in one spot, and the projectiles are going in strange directions.

“Strange behaviors are: - Projectiles: sometimes fire straight, and sometimes fire at an angle or slanted, or corkscrew”

Almost certainly, one problem could be:

You need to extensively use the “physics layers” system in Unity.

When hero H fires bullet B, the bullet B will interact with hero H as it begins its journey!

The solution to this issue in game engines is physics layers. In practice, you can’t do anything at all in Unity physics without using the layers system.

it is very likely you’d have to totally redo it using layers - before looking for any other problem. Fortunately it’s easy to do so.

BTW “spawn enemies” … if you mean using Instantiate(), generally you don’t instantiate anything during gameplay in a vid game. One uses a pool … here’s a long discussion!

So physics laters, hope it helps in some way cheers