Custom physic vehicle simulation! Project download included

1.3 is awesome, especially the auto transmission, the game camera movement and the color changing.

However I found a surefire way to end up in weird situations:
put auto transmission on, veer slightly to the side to avoid the obstacle course, pedal to the metal. Make an 180 turn when you see the wall while losing as little speed as possible and head back to obstacle course. You should hit the obstacles at 180+ kph, which… does weird things.

Once it threw me off the map completely, with the car in free fall below the map and the speedo increasing without limit. The other time, the car ended up sideways, wedged into the wall. Needs a value to kill player when he falls below the map and also a reset function for other weird cases.

EDIT: And before you think I’m only complaining, this is awesome, seriously thinking of incorporating it into my game :slight_smile:

Sure man, will add a killZ level and also a respawn function for the vehicle on the press of “R”.

thanks for the feedback ^^

Hi there! update 1.4.
Sorry about the voice and beign a little bit lost, I am very tired.

Hope you enjoy the update!

Sorry if this an obvious question but I am just starting to look into vehicles in UE4. What are the advantages of this vehicle setup over the PhysX vehicles in ue4?

-the possibility to have as many wheels as you’d like.
-Wheels collision are round instead of line trace so it look much better.
-It is ALOT easier to setup.
-It is very rewarding to do my own vehicle class from the pawn class instead of using the wheeled vehicle class :slight_smile:
-Having built that system myself, I know exactly how everything is done and why it’s done like that.
-Having a custom class like that made only in blueprint allow blueprint users to customize it so much more than starting from a c++ class like the wheeled vehicle class.

that’s pretty much all :slight_smile:

Thanks. The wheel collisions / easier setup sounds great to me.

I tried getting the UE4 advanced vehicle template to work good but nothing I changed resulted in good results with the vehicle flipping constantly etc.

I will definitely look into your project more in depth as I add vehicles to my project. Looking forward to your tutorial video.

Starting to record the first one just now :slight_smile:

Just noticed that the project uses Custom Collision Channels. Had a funny moment after migrating the car without setting up the channels first.

Any other settings to copy other than that (and input obviously)?

Version 1.4 seems to have compiler errors.

In 1.3 physics still behave a bit “wonky”.
In this video [^] the car hits a 10cm box at 70kmh and goes airborne (looks as if the car had almost no weight to it).
Setup left at defaults, any suggestions what to customize to keep the car more grounded?

PS: when I change “MassInKg” on the Body_mesh in the bp, I don’t really see any effect.

What do you mean? 1.4 works for me x) and also I know the mass in KG is not doing anything, I dont know why, maybe you could try adjusting the gravity scale in the project setting?

nope, that was all :stuck_out_tongue:

In BP_Dodge_Charger > Respawn Vehicle at SpawnActor I get:


Error COMPILER ERROR: failed building connection with 'BP Dodge Charger 69 Reference is not compatible with BP Chevrolet Camaro SS 69 Reference.' at  K2Node_SpawnActorFromClass_12"

I guess Respawn Vehicle has been copied from the Camaro to the Charger, so some references are invalid.
You should make Camaro a child class of the Charger (or create a “base vehicle BP” with Camaro and Charger as child bps).

Ah, that explains it then. Hope it can be fixed.
Temporarily adjusting gravity improves the issue with the car flying on every bump at higher speeds, but of course the whole physics simulation acts unnatural.

I opened the project for the first time. error. What is this error?

&stc=1

[hr]

Errors:

LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error COMPILER ERROR: failed building connection with ‘BP Dodge Charger 69 Reference is not compatible with BP Chevrolet Camaro SS 69 Reference.’ at K2Node_SpawnActorFromClass_12
LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error Can’t connect pins self and ReturnValue : BP Chevrolet Camaro SS 69 Reference is not compatible with BP Dodge Charger 69 Reference.
LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error Can’t connect pins ReturnValue and self : BP Dodge Charger 69 Reference is not compatible with BP Chevrolet Camaro SS 69 Reference.
LogBlueprint:Warning: [Compiler BP_Dodge_Charger_69] Warning [0013.34] Compile of BP_Dodge_Charger_69 failed. 3 Fatal Issue(s) 0 Warning(s) [in 62 ms] (/Game/Vehicles/Dodge_Charger_1969/BP_Dodge_Charger_69.BP_Dodge_Charger_69)
LogBlueprint:Warning: [Compiler BP_Dodge_Charger_69] Warning [0013.34] Compile of BP_Dodge_Charger_69 failed. 3 Fatal Issue(s) 1 Warning(s) [in 0 ms] (/Game/Vehicles/Dodge_Charger_1969/BP_Dodge_Charger_69.BP_Dodge_Charger_69)
LogBlueprint:Warning: [Compiler BP_Dodge_Charger_69] Warning [0013.34] Compile of BP_Dodge_Charger_69 failed. 3 Fatal Issue(s) 2 Warning(s) [in 0 ms] (/Game/Vehicles/Dodge_Charger_1969/BP_Dodge_Charger_69.BP_Dodge_Charger_69)
LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error COMPILER ERROR: failed building connection with ‘BP Dodge Charger 69 Reference is not compatible with BP Chevrolet Camaro SS 69 Reference.’ at K2Node_SpawnActorFromClass_12
LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error Can’t connect pins self and ReturnValue : BP Chevrolet Camaro SS 69 Reference is not compatible with BP Dodge Charger 69 Reference.
LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error Can’t connect pins ReturnValue and self : BP Dodge Charger 69 Reference is not compatible with BP Chevrolet Camaro SS 69 Reference.
LogBlueprint:Warning: [Compiler BP_Dodge_Charger_69] Warning [0013.42] Compile of BP_Dodge_Charger_69 failed. 3 Fatal Issue(s) 0 Warning(s) [in 70 ms] (/Game/Vehicles/Dodge_Charger_1969/BP_Dodge_Charger_69.BP_Dodge_Charger_69)
LogBlueprint:Warning: [Compiler BP_Dodge_Charger_69] Warning [0013.42] Compile of BP_Dodge_Charger_69 failed. 3 Fatal Issue(s) 1 Warning(s) [in 0 ms] (/Game/Vehicles/Dodge_Charger_1969/BP_Dodge_Charger_69.BP_Dodge_Charger_69)
LogBlueprint:Warning: [Compiler BP_Dodge_Charger_69] Warning [0013.42] Compile of BP_Dodge_Charger_69 failed. 3 Fatal Issue(s) 2 Warning(s) [in 0 ms] (/Game/Vehicles/Dodge_Charger_1969/BP_Dodge_Charger_69.BP_Dodge_Charger_69)
LogSpawn:Warning: UWorld::DestroyActor: World has no context! World: DefaultMap, Actor: /Game/Maps/DefaultMap.DefaultMap:PersistentLevel.DESTROYED_BP_DC69_Needle_C_CHILDACTOR_558
LogSpawn:Warning: UWorld::DestroyActor: World has no context! World: DefaultMap, Actor: /Game/Maps/DefaultMap.DefaultMap:PersistentLevel.DESTROYED_BP_DC69_Needle_C_CHILDACTOR_559
LogSpawn:Warning: UWorld::DestroyActor: World has no context! World: DefaultMap, Actor: /Game/Maps/DefaultMap.DefaultMap:PersistentLevel.DESTROYED_BP_CCSS69_SteeringWheel_C_CHILDACTOR_5
LogSpawn:Warning: UWorld::DestroyActor: World has no context! World: DefaultMap, Actor: /Game/Maps/DefaultMap.DefaultMap:PersistentLevel.DESTROYED_BP_DC69_Needle_C_CHILDACTOR_560
LogSpawn:Warning: UWorld::DestroyActor: World has no context! World: DefaultMap, Actor: /Game/Maps/DefaultMap.DefaultMap:PersistentLevel.DESTROYED_BP_DC69_Needle_C_CHILDACTOR_561
LogSpawn:Warning: UWorld::DestroyActor: World has no context! World: DefaultMap, Actor: /Game/Maps/DefaultMap.DefaultMap:PersistentLevel.DESTROYED_BP_DC69_SteeringWheel_C_CHILDACTOR_79

LogDirectoryWatcher:Warning: Failed to begin reading directory changes for …/…/…/…/Launcher/Unreal Projects/4.14/Vehicle_Experiment/Plugins/. Error: Sistem belirtilen dosyayı bulamıyor. (0x00000002)
LogUObjectGlobals:Warning: Failed to find object ‘Class None.’

LogScriptCore:Warning: Script Msg: Attempted to access index 1 from array Tags of length 0!

LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error COMPILER ERROR: failed building connection with ‘BP Dodge Charger 69 Reference is not compatible with BP Chevrolet Camaro SS 69 Reference.’ at K2Node_SpawnActorFromClass_12
LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error Can’t connect pins self and ReturnValue : BP Chevrolet Camaro SS 69 Reference is not compatible with BP Dodge Charger 69 Reference.
LogBlueprint:Error: [Compiler BP_Dodge_Charger_69] Error Can’t connect pins ReturnValue and self : BP Dodge Charger 69 Reference is not compatible with BP Chevrolet Camaro SS 69 Reference.

Same thing I mentioned in the last two posts. Go into the displayed blueprint and disconnect “Respawn Vehicle” - you can also just click yes and run the project, everything else should work fine.

If you want to fix the issue, you’ll have to replace 3 references in the mentioned function - “Get Class”, “TP Camera” and “FP Camera”.

The problem’s been solved. Worked. Thank you very much :slight_smile:

sorry guys, I thought I had fixed this before uploading 1.4, guess I did it after x) And yess, adjusting the gravity value in the project settings help alot. I also make the vehicle not drift at all when taking a turn at 180 kmh. Not sure how to make any of this right…

Edit: value of -1500 for gravity looks good, make the vehicle much less likely to fly and much less drifty, but still drifty at high speed to a resonable extent. I always found the gravity to be too weak when jumping with a character, now it seem right.

Doesn’t work for me:

Charger @ Gravity -1500 [^]
Charger @ Gravity -2500 [^]
Camaro @ Gravity -2000 [^]

Except for springarm length all values are default.

Edit: I guess this is a relevant topic for the mass issue: Mass doesn’t seem to affect “spring like” constraints
Unfortunately it doesn’t provide much in terms of answers.

Well, It does fly alot less high, maybe add some angular damping to the body so that it does not want to do backflip so easily? Also did you notice you are hitting those bumps at 50 to 60 kmh? that it something I would not want to do in real life xD

I’m still experimenting with it, but it looks promising. Angular Damping of around 100+ helps greatly but unfortunately dampening is one float value and not separate for each axis (it drastically changes steering - car slows down to a crawl while maneuvering. Maybe it can be countered by adjustments to the way force is applied, I don’t know at the moment). I’ll also try an approach where the physics angular velocity is negated on one axis during Tick.

Yeah, sure xD but I would not expect to die a horrible death when hitting a curb at that speed either :wink:

hahahaha some backflips in a car never killed anyone, pffff.

And yeah, the damping was a bad idea, try and get the angular velocity of the Right direction vector, and cut it in half or wathever in event tick, this will make the baclflip effect lot less prone to happen I think.