I have a real time battle system with a 'follow the leader' type of movement AI. You can turn off the movement AI by pressing a key so that you can position your various party members without them following you. The problem with that is that when the movement AI is inactive, gravity seems to be disabled.
For example, I have an enemy with an ability that knocks you flying back and upward. If the character is not currently being controlled by the player and its Move AI is off, it will not fall from that height unless i re-enable its move AI or take control of it (so that it no longer needs a movement AI).
Using the gravity option in rigid body just makes it go through the floor somehow. Using the gravity option with a capsule collider makes it fall but it then tumbles around as if it is a beachball (also, it doesn't walk around correctly either).
I think this is related to the whole 'combatants spawning above ground' thing and it seems like the implementation should be that gravity is always active no matter what unless explicitly disabled by some sort of option - rather than only being active when moving is happening.
Potentially this could be something as simple as putting a
this.controller.Move((Physics.gravity) * t)
as an else to the if(doMove) condition in SimpleMove.cs, though I'm not sure if that would cause issues or if it's the right way to do it.
Incidentally, is it possible to 'override' the DLL scripts with same-name copies of the scripts from the source code, so I can test if these things work without compiling ORK (which I'm not even sure how to do)?
You may also need to disable it from the player you control since this player will fall just fine even if he's not moving. But you may not, since due to his falling, he is moving, so the script should not activate until he is on the ground.
Also, for having gravity and stuff - that's up to whatever style you want for your game. E.g. rigidbody that constraints rotation will prevent the tumbling.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Yay it works, thanks for pointing me in the right direction!
But there is one problem I still can't figure out. I have multiple player combatants who can become the player. The currently controlled combatant has his own move script. But once the MoveAI movement script becomes attached to the combatant, it won't get removed when that combatant becomes player controlled, which then causes interference as the two movement scripts battle it out. Is it possible to unattach or disable the move AI's custom movement script when a combatant is player controlled? Right now I'm doing the following which works but I don't want to have it hard-coded and it would be nice if the Move AI's script would remove itself whenever the player took control of the combatant:
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Thanks!
Using Update() is needed to do some things (like jumping, or falling), so that means I either need to have those in separate scripts and then have crazy checks to compute the overall movement, or I need to manually destroy the scripts attached by Move AI whenever the ally combatant becomes the player to prevent interference.
So maybe disabling the Move AI script is worth while for ORK to do automatically when the combatant is player controlled, or alternatively provide some type of MovementUpdate() function to the AI that does the same thing as Update() but isn't called when the Move AI is disabled.
Just feedback at this point since I implemented work arounds as described :)
E.g. do the movement stuff in the update function only when a flag (bool) is set to move to a destination (i.e. position function will set the flag to true, stop/reaching the target will set it to false). If the flag is false, only do the gravity stuff.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
That second approach works until the Ally becomes Player controlled by the player. In that case the flag in the AI control script will be false and gravity will happen from that script, which will interfere with the player control script.
Ideally you'd want two control scripts that act exclusively such that when one is active the other is not - one when the player is controlling a party member, and one when an AI is controlling it. But right now this is only possible through scripting (e.g. if you listen for when the player changes and disable the AI control script).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!