Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
gunair's avatar
gunair
Explorer
12 years ago

From pedestrian to pilot - how change controller ingame?

Hello from Germany,

I'm working on my little demo map and although I'm an absolute Unity beginner, I solved all problems so far. It's a lot fun to find the way to reach the goal...

But now, I need your help. At the beginning of the demo, my character is a pedestrian, walking (and running) through the forest of my map. So I use the OVR character controller. Everything works fine (and looks good! :D )

But than, he should find a kind of helicopter. I have the helicopter controller working (not as good as I wants, but it works okay too).

Now the problem. How could I switch the controller type, the second he enters (mount) the helicopter? And how could I attach the character to the helicopter automatically, so that I can fly the helicopter with my character onboard?

Perhaps it's simpler than I think, but I have no idea.... :?:

Even a link to a tutorial or a video would help (haven't found either)

Greetz,
Gunair

PS: Anybody here, using CH PRO Pedals with Unity???

5 Replies

Replies have been turned off for this discussion
  • Caine's avatar
    Caine
    Honored Guest
    With the caveat that I am still learning all of this, I'd suggest something like follows:

    -collider on your player set to a layer that only interacts with collider I refer to in point below;
    -collider set to trigger & rigidbody on helicopter interacting with collider above;
    -script on player so that when player collides with helicopter it instantiates a stationary version of the player that is parented to the helicopter & destroys the original player;
    -helicopter control script on helicopter so you can actually fly it.

    Scripting the transition shouldn't be too tough, it would work similarly to how I instantiate a ragdoll version of my player on death. Hope that helps!
  • maybe a good approach would be when you "get in" the hellicopter, change some value to true to change how the character input controll works for flying, move the character controller into the helicopter cockpit, and then somehow transform the helicopter attatched to the camera like Caine said.

    actually now that I think about it, it will probably have to effect the gravity and other stuff when you get in the helicopter, so maybe a global variable declared up top that the gravity and whatever else can also have access to with the "in the helicopter or not" value.
  • I have a JetPack in my game, when I put my JetPack on I make my character a child of the JetPack, and position it in the correct localPosition of the JetPack. At the same time I also disable the players control script and enable the JetPacks control script. Then I use forces to move the JetPack around, the player being a child moves with it.
  • I MADE IT!!

    Thank you all!

    Human's brain is a strange thing sometimes :D . After many days without ANY idea of solving the problem, it changes minutes after writing this thread! It was like "resetting my brain", through writing the problem down. The initial idea came up...the rest were some keywords in your threads, like "destroy player", "parenting", etc to show the right direction...

    So, in the end, it was easier than I thought (isn't it always so, when you know how to do tings? ;) ). I have to add, that I have no idea of writing program code (c or javascript or so...). I'm using the amazing "PlayMaker" Plug-In. And here is, what I did:

    - Basic was using the "normal" pedestrian,- the OVRPlayerController (incl. CameraController). Everything as usual. Besides, that I tagged it as "Player"

    - At program start I set up two things:

    Having my helicopter, complete with helicopterController script and an OVRCameraController as a heli "child" (camera correct positioned in relation to the heli). I DE-ACTIVATE it a the start. The heli (with the added pilot body) is not visible.

    I placed a heli duplicate (without pilot body),-and without Controller and OVRCamera - , as a just visible clone at the exact heli position.

    - Placed a trigger box, - which can only be activated by a "Player" tagged object - , around the heli cockpit area.

    - When the trigger is activated, it does three things:

    Destroy the "pedestrian" OVR PlayerController.
    Deactivate the "visible" heli clone.
    Activate the heli object, incl. HeliController script and (second) OVRCamera.

    That's all!

    Thank you again, for your help!

    Greets from Germany

    gunair
  • Caine's avatar
    Caine
    Honored Guest
    Glad to hear that! One thing I am really enjoying about game dev is that there are so many different ways to get the result you want. Look forward to getting a chance to try your demo :)