Hello folks,
I need to pick some ideas over here. So this is the situation:
I have a scene (RPG View - Not Top Down, think Chrono Trigger) with a guy, who’s got a parent playerObject, and two child objects, Player (for the sprite), Shadow(Feet). The Player and Shadow are just sprite renderers without rigidbodies. The Shadow has a box collider with a trigger set on.
Currently, the parent object has it all - the playerController, the necessary box colliders, rigidbody2D, except for a sprite renderer.
So far I have managed to get my guy running, even JUMPING (I am so excited about this since I figured this one out by my self),attack animations what not. Last night I came up with a “Falling” Logic.
This was all possible because I can animate the sprite in Player independent of the shadow (Just move the transform.position.y +/-, while checking for the object’s localPosition relative to the parent), and similarly, the falling logic as well - keep the shadow still down, move the Parent Object down relative to the shadow.
However with that second one, the falling logic, I cannot move the shadow up and down (but I can make it move left and right) because to keep the shadow still in its y axis and NOT move with the parent as the parent moves down towards it.
Here’s my thought right now: What if I remove the rigidbody2d from the parent, remove the colliders, and script, and move the rigidbody2d to the Player and Shadow children, put the big colliders in the Player, and necessary one for Shadow to prevent NOT colliding with anything, and then move these two children independent from each other by placing a Movement script that can be used by either of them, a Jump script for the Player object, a fall script for the Player/Shadow and NOT have anything on the parent? But if I do this, disadvantage would be that I would need to make sure Player and Shadow transforms are in sync.
Advantage would be the jumping and falling logic would be easily maintained by keeping them in separate scripts.
In most tutorials they have one giant playerController script that handles everything of a player object.
Is it realistic to separate the controller script into chunks for movement,jumping,falling,attacking and allocate them to necessary Objects? This would make them re-usable right? But why don’t tutorials encourage this?
[Sorry for the long thread, I’ve been losing sleep for the last few days because of this so I want to pick your brain on this.Thank you.]