Download

How can i possess a different character and unpossess my current one?

I basically want to enter a vehicle just like you would in other games by approaching it and pressing E, the vehicle itself is a character ect, any guidance would be highly appreciated.
Thanks.

Create a sphere or a box component in your vehicle BP. Make it large enough for your character to overlap since you’ll use it to generate overlap events so that your character can posses the car only when you are near it.
Then go to your player controller BP, Event begin play > Get all Actors of Class(your vehicle BP) > ForEach Loop > Cast To(your vehicle BP) > Set it as a variable. Do the same for your human character and then setup your spawn and posses events using those variables and the overlap event of the sphere(or box) you created in the vehicle BP.

Thanks for the reply, however i am really struggling to get my head around this, i am usually quick to pick up on these things, i know this is HIGHLY wrong but can you point me in the correct location from this? i am doing this in the vehicles blueprint.

Not the vehicle BP, Player Controller BP. Create one if you dont have it already. And then do this:

In this example Challenger is my vehicle and Kowalski is the fps character, and they already exist in the level when the game begins.
There is more to it once you do this, but you should be able to figure out the rest once you get the pawns inside the player controller. If you cant, let us know where you are stuck and i’ll help you out.

Thanks for the reply however i did already have that bit done, what i was showing was my attempt at actually switching the player character to the vehicle. and i think i would need to see the rest of that blueprint as mine ends as soon as soon as i get the part where i set the variable.

Alright, i’ll show and explain the rest of my BP but i want you to turn all of this into a tutorial for the community when you get it working!

So first, as i said both the fps pawn and the car exist in the level. In my setup i needed to use the car as player pawn at level start:

Now after this comes the BP network i posted earlier, in player controller.

Then, in player controller again, we get the vehicle variable we set, take out the collision sphere from it and generate begin/end overlap events for it like so:

We use those events to set booleans to find out if we are near the car or not. Also set 2 bools for the car and the fps player so that we know who we are controlling right now. If it is Kowalski, then we posses the car; if it is the car, then we spawn a Kowalski and posses him.

And then we setup the key event:

If we are Kowalski then we posses the car and destroy Kowalski; if we are the car then we spawn a new Kowalski and then posses him.

And thats pretty much it, you dont need to touch your character blueprints. Let me know how this goes.

Thanks for all the help, i really do appreciate all the effort you went through to explain this, i have got it working to an extent right away, but instead of deleting the character, i am attaching him to the “seat” socket and playing the driving animation i made, so far so good, now i just need to sort out the overlap stuff so i cant get in when i am far away, as for the tutorial, i will put it on my todo list :slight_smile: thanks alot.

Awesome. If you came that far, overlap part is the easiest. You may want to destroy the pawn and then spawn the animated skeletal mesh when you get inside the car though. I’m not sure but if you keep the pawn inside the car collision may go nuts so keep in mind that it may be one of the reasons if things go wrong. And please do the tutorial(written tut. with screenshots, no need for a video) at some point, i know a lot of people will need this in the future. :slight_smile:

Would horses be considered “vehicles” or is horse riding an entirely different animal from hopping into a car? (I guess riding any creature qualifies)

Would the method be very different? Especially if I wanted my character to be able to shoot arrows or swing a sword while riding - it’s simultaneously maintaining control of both the “vehicle” and the character. Getting in a car totally hands over control to the car, but with horse/creature riding, the rider’s arms are available for actions. Or even stand on the horse, lean sideways, ride backwards, etc.

Those familiar with Shadow of the Colossus know what I mean. You can practically do a circus act on that horse. Standing, jumping, shooting, twisting, and more.

At some point I will eventually desire this ability for my game, but that’s a long while in the future. Still, the question is already here.

How does riding/driving animals compare to riding/driving vehicles?

Its exaclty the same, youre trying to control somethink, in the case of a horse you will need to make a better work with animations, blending them etc.

For sure, you can make the “vehicle” to fire arrows, etc etc, everithink you want it to do.

Hi everyone! I did everything as written Jacky, and i find some problems. (Sorry for my bad English)
In first: If i copy my car on level, I can’t enter in the first car. Only in copy car and when i controlling this car the wheels are turning on both machines.
And second: When start game with 2 players, the player on the server laging (slows). And if the player on the server sits in the car he starts to play at the level of default.

That may be because i used the player controller to set this system. I needed only one car so i may have missed the side effects of it. Feel free to post how you fix it here!

Jacky, I have to thank you!

I’ve been searching, far and wide, for some sort of a tutorial about this. Haven’t found one until I saw your post, did the steps you described and everything works. Granted, I didn’t understand half of what I was doing, but now at least I can actually dive into it and learn.

Just wanted to say thanks :slight_smile:

Glad you found it useful! I would make a detailed tutorial if i had the time, but feel free to make a Wiki tutorial yourself when you understand it all. :slight_smile:

Edit - 23.09.2014:

Sample project and BP setup for multiple vehicle interaction: GTA Style Vehicle Interaction - Project File Included - Community Content, Tools and Tutorials - Unreal Engine Forums