Player can walk, ride a horse with also the ability to fly

Hi all,

We are looking to make a player walk, ride a pegasus on foot and on air. I am looking into how we can best structure the scripts for this. As per the one of the topics here (Player Entering Vehicle), this will be possible if we have trigger detection, playing a couple of animations and changing control modes in code. What would be the best way to structure the scripts to get them to work seamlessly?

I already have working controls for walk, ride, and fly in three separate .js scripts. However, when I try to switch control methods (changing scripts), I end up spawning where I started (0,0,0) as opposed to where I should be after walking/riding/flying a few mins. Is this due to it being written in different scripts? Should we just include all these controls in one script bunched together in if-else statements?

Thank you so much for your patience and hospitality. Still fairly new here and I am trying to grasp everything with tutorials and whatever resource I can get.

Hi @spike_bump,

It’s good that you are thinking proactively on how to structure your code. That can solve a lot of headaches down the road when the code gets more complex.

It’s a bit difficult to help you out with that specific bug, out of context. But if it helps: usually when you switch control from one player/camera script to another, you need to make sure that the script that is getting active starts with the right input (e.g. starting position should much the active position of the player entity instead of a zero/empty vector).