I am having trouble getting a vehicle to stop when you exit (unpossess) the vehicle. I can’t seem to figure out what I need to do in the Sedan Blueprint.
What happens specifically is when I exit, the Sedan just keeps going. It does not even slow down.
I found out a fix (kind of) after messing around for a couple of hours with BP
I just made it so you cannot exit unless you are not holding w or s you do this by adding BOOL and then branch saying if it is true then do not get out of car (however your BP for that looks) and if its false then run the BP to get out of the car hope this helped…
Having the exact same problem. Weirdly enough, even if I set the vehicle to set it’s throttle to 0 when the vehicle is unpossessed the vehicle keeps moving anyway. If I set the throttle to be -1 when the vehicle is unpossessed, the vehicle moves backward though. So it seems as though the vehicle will set it’s throttle to any value except 0 when it is unpossessed.
Seems a bug (as of 4.21.1): the throttle won’t be controlled unless it has a controller. So the this solution (or something similar) will work. So when you detach a controller, whatever is the last input will hold.
Create an AIController which does nothing but set the throttle of the controlled vehicle to 0 (in the tick)
Unpocess the car from player controller
Pocess the car by your new AIcontroller
Profit
This is the working solution for UE5.1 with chaos vehicles, seems if chaos vehicles are not possessed they won’t stop moving.
This isn’t a solution to the problem OP is having. Imagine the halo warthog, where players are jumping into and out of the vehicle at any given moment; You want it to set acceleration and steering back to 0 when the driver exits, but still otherwise have it behave like a vehicle, at the very least, while it coasts to a stop.
That said, If the vehicle needs a controller to receive any input, so be it, but it would have been nice if it threw out a warning somewhere so one wouldn’t spend a bunch of time trying to figure out why the seemingly obvious solutions aren’t working.
Doesn’t need to be a vehicle if there is no accellerarion. You can simulate physics on a mesh and retain the last impulse or apply the same value of it.
Better yet, you can calculate it your self and use a timeline to keep it moving.
Genrally, if it isn’t possesed by a player everything within a vehicle class becomes useless…
I would argue that is a pretty use-case specific solution. If you have more vehicles available then you would want simulated, like GTA or something, then sure, that’s probably a very reasonable idea.
If you’re making a smaller multiplayer sandbox game (ala Halo), then all the vehicles on the map could and would potentially all be driven at the same time, so that overhead’s got be budgeted in anyway. A system to swap out vehicles with non vehicles would probably not net you much usable performance gains at that point, but it would definitely cost development and support time.
and if you’re like me and you’re just playing around, then performance isn’t really a big deal in the first place, and the problem (like OP) was not understanding why the vehicle component wasn’t accepting input when there was no player controlling it: @Todd.Vance was right, it wont accept input without a controller. (Which probably makes sense in the context of how input in pawns works, but in the moment it seems very counter intuitive that it was ignoring input… at least to me)
For those looking for solutions, no need to bother with dummy AI controllers or making a custom movement component anymore, there is “Requires Controller for Inputs” boolean flag in the new ChaosVehicleMovementComponent.
Once you unpossess and want to update the input values though, you might either want to add delay node (if quick and dirty) or some check for whether if a driver is still present in your car’s input events, because the InputActions will also fire their “completed” events after the unpossession.
Then continue with the exit vehicle/un-possess code.
Adding that delay seems to work but not if below ‘0.3’. I guess if you have an exit vehicle animation that is say 3 secs long, you could trigger the animation first, then do the above, then set the delay to however long the animation is.
With this solution, you don’t even have to put HandBrake if you don’t want to (I put it for personal preference), and it works it won’t drive off anymore, thank you soo much, I spent hours looking for this fix lol