antfarmar / Unity-3D-Asteroids

A simple Asteroids clone. In 3D.
The Unlicense
65 stars 15 forks source link

Refactor ship input & Particles bugfix #13

Closed ghost closed 8 years ago

ghost commented 8 years ago

Changes

Refactor ship input

User input controlling the ship has been moved to ShipInput.cs This groups all code related to input in one place which serve a few benefits:

New project members can easily find all ship input code in a single location. This makes it easier to understand which buttons to press.

Input specific logic can be placed in ShipInput. For instance, GetForwardThrust only return values in the range (0, 1). Ship logic code doesn't have to worry about sanitizing ship input.

Particles no longer smear over screen when crossing edge

The problem was that the particle system on the Ship prefab emit particles when it detects movement. Unfortunately screen wrapping confuse the particle system into emitting lots of particles which smeared across the entire screen.

My solution was to put a script on the particle system that listens for screen wraps and disables emission for one frame.

Image of Particle Bugfix

Merging tips

If you get conflicts in Ship prefab, ignore my changes to the prefab and simply add ParticleScreenWrapperBugfix to the Thruster child on the Ship prefab yourself. After that, your particle system should work fine wrapping across screen edges.

antfarmar commented 8 years ago

I'll have to look at the code. Frankly, I wasn't really expecting any watchers, let alone pull requests!

While I don't see any real issues with my simple implementation of input, I was aware of the particles issue, as you can see in the ScreenWrapper code, where I deactivated the gameobject before changing position, then reactivated it. (This was before deactivation == player death).

I guess individual Components could be disabled there also.

ghost commented 8 years ago

I'll close this pull request and split it as two separate requests so you can cherry pick easily.