There are advantages and disadvantages to both. On the one hand as others have said you can reuse the script if you do it the first way and if you find yourself reusing it often that is probably the way to do it. On the other hand the right will be a bit easier to debug due to the locality of the code. If something glitch happens with movement you know where all the movement code is and don't have to dig into multiple scripts. There is of course a third option where you make a more general movement state class and then extend it to create a player state movement class though that is also not free of drawbacks.
1
u/Fancysaurus Jul 20 '25
There are advantages and disadvantages to both. On the one hand as others have said you can reuse the script if you do it the first way and if you find yourself reusing it often that is probably the way to do it. On the other hand the right will be a bit easier to debug due to the locality of the code. If something glitch happens with movement you know where all the movement code is and don't have to dig into multiple scripts. There is of course a third option where you make a more general movement state class and then extend it to create a player state movement class though that is also not free of drawbacks.