hatfield-c / rotkr

Rats! Of the Kar Re-Bein by Katin Games
0 stars 0 forks source link

[ROTKR-75] An enemy ship prefab will be created #75

Closed hatfield-c closed 4 years ago

hatfield-c commented 4 years ago

Currently, we are using a customized version of the Waso Moli prefab. However, there needs to be a unique prefab for our basic enemy ship, which has a unique skeleton and unique hunk layout.

Furthermore, there should be fewer hunks on this new ship, and they should be larger. The profile of the ship in general should be larger, and should be easier to hit by the player.

hatfield-c commented 4 years ago

I've created a basic enemy prefab based around the idea of a hollowed out milk carton, however damaging the ship has proven difficult. I will need to do experiments to determine if this is related to continuous collision detection, or if I'm just a bad shot.

hatfield-c commented 4 years ago

After testing, I have confirmed that the primary issue is how hunks are being attached to the ship via fixed joints.

Previously, we had set the fixed joint connection strength incredibly high, as this was the only way to prevent the joints from flying off the ship when it accelerates/decelerates.

This occurs due to how force is calculated:

Because the mass of an object is constant, it essentially boils down to

So when the ship accelerates, the hunks and their fixed joints experience an equivalent increase in force against them.

This is all and well and dandy, however this presents a problem with the projectiles. If we set the joint force too high, the projectiles cannot knock any of the hunks loose. However if the joint force is too low, then all the joints will fly off the moment that the ship accelerates, or crashes into something.

We can potentially try to address this in a number of ways, such as increasing the mass of the projectiles, which will necessarily increase the force they exhibit onto the hunks during collision. This is not perfect however, as when these heavier projectiles strike the static colliders of a ship, the ship is sent careening off due to the massive force imparted upon them.

We can also try lowering the speed and acceleration of the ships, which will also allow us to lower the joint force as well. The problem with this being, that there is a lower limit onto how slow we can make a ship before it becomes nonviable as an enemy. Furthermore, this also creates an upper limit on how fast ships can go, and we do not know how constrictive this upper limit will be.

hatfield-c commented 4 years ago

There is also the possibility of following the same logic we used to attach the rats to the ship - i.e. we remove the fixed joints on the hunks all together, and set them as childed isKinematic rigidbodies. Then with the OnCollision method, we simply detect if the incoming collision occurs with enough force to knock the hunk off, at which point we dechild the hunk and turn isKinematic off.

While this would likely work, I am hesitant to go down this road unless it is absolutely necessary. The whole reason of selecting FixedJoints to attach hunks to the ships was their generalized behavior, and their ability to deal with multitudes of physics situations without the creation of additional logic. This isKinematic route would grant us greater control over how hunk physics is performed, but this greater control can be a curse, in that our solution might become more rigid and less able to respond to a wide variety of situations.

Presently, I am going to continue testing different configuration possibilities with the FixedJoint, before I make a decision.

hatfield-c commented 4 years ago

I did some more digging, and it would seem that the new ship prefab was using the very old joint force value of 15,000, whereas we typically use a new value of around 3,000.

After setting the value to 3,000, the hunks appear to behave quite nicely. As such, I think we can move forward without modifying the hunk joint logic, but this is definitely something we need to be wary of.

hatfield-c commented 4 years ago

This issue is ready for QA.

To QA, go to the MovementTesting scene, and do the following:

KevinDCo commented 4 years ago

This issue has passed QA