I’m trying to create a remote control car in effect (in VR) where you are controlling a car. You yourself remain stationary.
I’ve been using the car template given by unreal, previously i’ve just been possessing the car pawn to control it but using a camera in the scene. But doing this you lose the audio listener position (using FMOD, it thinks you the pawn are in the car so 3D properties are not correct).
So i’m now trying to keep control of my main VR pawn, but send the input values to the car and use the forward and right axis for setting the throttle and steering respectively. The values are being sent to the class just fine, however the car doesn’t move.
I’ve tried looking through the car cpp but nothing is jumping out at me that means it wouldn’t work the same if not controlled/possessed by a pawn.
I may be missing something obvious so any suggestions welcome - but has anyone come across this or a way to control the car without possessing it?
you can only possess one pawn at a time. but you can get a reference to your car (pawn, or regular actor) and call events on it using regular function/event calls. your input handling can stay in your playerController or vr pawn.
Thanks - yeah i’ve been trying to pass it as separate function calls. So far i’ve figured out I can do this fine if the actor/pawn already exists i.e sending values to the appropriate throttle/steering controls the car as expected, but if I’m spawning it then sending values to SettingThrottle/Steering doesn’t do anything.
I’m sure there’s a way but for now I’m just hiding/revealing the car when appropriate.
can you show some code how you spawn and how you communicate with the car?
If the game is single player you just have to enable input on the car.
If it is multiplayer then when you want to take control set (Server-side) the Owner of the Car to be the already possessed Pawn or PlayerController then you can call RunOnServer events directly on the Car when the Client received the Owner update. Don’t forget to also enable Input on the car.
Then the client can have Input Events directly on the car and they call RunOnServer events.
In C++ you have a callback client-side for when Owner is set called OnRep_Owner. Any RunOnServer event calls before the Owner is valid will be dropped.
How did this turn out? Any tips for someone walking the same path?
Here’s a great post that I came across, and I’ve been searching for this kind of post for the past week or so. Thank you very much and will be looking for more posts from you.