Trouble with Changing default Vehicle Components and vehicles in general


I fixed the issue or to be more exact i didnt understand the wiki entry from Rama (thanks you so much Rama)


AKaoscarWheeledVehicle::AKaoscarWheeledVehicle(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP.SetDefaultSubobjectClass<UKaoscarMovementComponent4W>(Super::VehicleMovementComponentName))

	UKaoscarMovementComponent4W* UkaoscarMoveComp = Cast<UKaoscarMovementComponent4W>(VehicleMovement);

PCIP.DoNotCreateDefaultSubobject is still not working for me but gladly i dont need it

I will now try to get my Steering to work and will update this when progress is made


I am trying to extend the wheeledvehicle and vehiclemovementcomponent classes.

So that i can have a custom movementcomponent in my custom wheeledvehicle class.

But im having trouble to change the default subobject of my wheeled vehicle class.

PCIP.DoNotCreateDefaultSubobject … isnt working for me at all. The default Object will still be created.

PCIP.SetDefaultSubobject is working but i get crashes when i start the editor because i have to init the object in the constructor.

When i do that i get 2 subobjects.

AKaoscarWheeledVehicle::AKaoscarWheeledVehicle(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP.DoNotCreateDefaultSubobject(AWheeledVehicle::VehicleMovementComponentName).SetDefaultSubobjectClass<UKaoscarMovementComponent4W>(TEXT("kaosMoveComponent")))
KaosVehicleMovement = PCIP.CreateDefaultSubobject<UKaoscarMovementComponent4W>(this, TEXT("KaosMoveComponent"));
KaosVehicleMovement->SetIsReplicated(true); // Enable replication by default
KaosVehicleMovement->UpdatedComponent = Mesh;

When trying just to set the default and do nothing in the constrcutor it compiles fine but the editor wont start up.
if there’s an error in this because i didnt copied that one but edited it just here by hand!

AKaoscarWheeledVehicle::AKaoscarWheeledVehicle(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP.SetDefaultSubobjectClass<UKaoscarMovementComponent4W>(Super:VehicleComponentName))


So my current situation is that i got 2 of the same components in my bp one made from the super and one from my class.
OR i could get one unchanged default movementcomp and mine. But this is not better than having 2 of mine or is it?

The question now is how can i avoid that or get finally rid of one of them. So either only change and get the default of the super or deactivate the default and create only my own.

Or if this isnt possible right now due to some bug … the question is will i have side effects from using the bp as it is now?
The testing part i will do tommorow if nobody has a better idea till then and when it has side effects then i can forget reusing the vehicle classes all together an rip what i need from them and will have to write new classes that just inherent from pawn without any components i dont want.

This might be the best solution anyway in the end because i dont know what trouble awaits me around the next corner by using the vehicle code.

The next part u can just skip if ur not interested in my overall vehicle exp. so far.

I encountered some oddities and stuff i found out:

For example in the tutorials u create a collision box for the car and spheres for the wheels. But in reality the spheres have no effect at all because the car uses the custom wheel collsion shapes from the wheel blueprints for collision and physx.
At least in my project. The wheels also will still go through walls with or without extra spheres, snce to my knowledge physx only tests downwards for ground collision and nothing else.
When i check the box for not creating the shapes even with having spheres the car wont work for me.

My current main reason for extendending the vehicle class is so that gamepad steering input will be given raw to the wheels instead of just adding till it got to the maximum degree which is only suitable for keyboards.

And since my cars will be of another scale than a normal car i wanna have my own initial setup.

I also trying to find out why the car has something like a turnupright function in most situations where it should just topple over. I looked at the classes and in physx without luck so far. And dont get me wrong a dont roll over function is something i would most likely use later but i want control over it when it fires and how it behaves. I know im not alone in the quest for an answer to that but so far nothing.

Another Trouble i got figured out is how to change the tires … thats a real easy one :smiley: all one has to do is using a wheel with a bone and attach it to the wheel bone.
Beware this isnt working with static meches because statics dont get any simulation or animation data!
Thats something that would be great in the tutorial along with other detailed descriptions how to do damage cloth and breaking stuff off a car even if thats not that hard to do if u make the connection to the whole joints sockets and weapons documention. I have to admit since im building a racing game weapons are not my main interest at this point ;D SO i overlooked it for a while. And a socket isnt really needed even if it doesent hurt, at least when u attach it in the bp maybe it is more useful when doing it with code?

For me the naming suspension bone is actually misinformation which can lead to missunderstandings between programmer and artist and its very difficult to explain that the suspension bone has nothing todo with the suspension of the wheel and therefore the car :smiley: instead its more of a hinge for getting the animation (stretching) of the mesh for the suspension right. And BTW that is really ugly to look at from a close up or with higher suspension settings.
And i only knew this because i read the physx documentation for their car part. Otherwise i might still not sure if that bones does anything to the wheels. But as things are… u dont need them at all for a moving car.

The vehicle class is done for the most part like its being done in the physx documentation.
I expected (having no idead and background in physx) a more complex and real world setup specifically meaning a suspension setup with realistic bone structure for the wheels.
Like others who do cars i wish for a suspension bone setup where u can actually see the wheels going in an arch and parts realistic moving having trouble settling for the just up and down and fake mesh stretch animation we have now.

I have to admit that this is a luxory problem that in most cases isnt a problem at all because most car suspensions are not visible. And Therefore most games which will feature cars wont miss this a bit.
And who else can u get ahead of your competition if not by doing something diffrent.

I understand that u cant get all for free and im trying to get the job done with what i have and i am happy to have an vehicle made by epic at all :smiley:
And in some ways it forces me to dive into programming instead of just fiddling around with bps. So thats a good thing in the long run even it may cost me some hair along the way.

Im sorry for the long post but i had to get that of my chest ;D

Actually this is the only part I can help with at the moment, but I feel the same way about the vehicle setup as it currently works, it’s great but has some small issues that I would like to fix/modify in code. I am also digging through the vehicle code to see what can be done, and will start making changes soon as well. :slight_smile:

This is entirely true, but the spheres are needed in order to work, but don’t really do anything. For open-wheeled vehicles (I’m assuming you have a dune buggy, or similar setup where the wheels are outside of the body) without adding any new geometry will cause the wheels to drive right through objects. The only way I have heard of to fix this is adding a mesh over the wheel (like a fender), then it will be counted as part of the body.

Or you can try adding another primitive component (box) to the base mesh in the Physics Editor (so there are 2 boxes attached to the mesh), then scale down the box and place it over one of the wheels (make sure the box will not hit the ground), then test that wheel out, if it works, place one on each wheel.

This can be done without code actually, I have attached an image at the bottom of this post showing the input settings, for steering you only need the one Gamepad Left X, then in the vehicle blueprint details you can adjust the the “Vehicle Input” section, there is a value where you can adjust the rise/fall factor for the input, I recommend using 1.2 & 2 for the two values.

All of that can be done outside of code as well, I will search for a little bit here, there is a video showing off a system with 50 bones (roughly), it is really advanced, but surprisingly simple. I will post you a link here when I find it :slight_smile:

**EDIT - And here it is: Xenomata UGV [possibly eternal WIP] - Work in Progress - Unreal Engine Forums

**EDIT # 2 - Removed the image, sorry I misread the issue. I will play with the settings again to see if it is possible to do a 1:1 ratio on the input and get back to you.

Thanks for taking the time and link.

OK i have that diving into objects effect even with the spheres.
I was going with the bumbers to fix that but maybe i give them spheres these days another shot.
edit: maybe i have missed some collsion checkbox or my tires are too small(around 14 cm).

Maybe some finetuning of physx settings is needed on my side. There was a variable for how deep an object goes into another before a collision is triggered right?

Ok the image took its time but now i can see it. From the look of it I did the exact same thing and the wheels wont stop at the degree the gamepad has 33 degree for example instead it goes all the way till it reaches the 70 max angle which is the default.
But i have to admit that my throttle is working and behaving correctly (it will not always rise to top) but i have other strange effects with low throttle input and wheels spining sometimes in the other direction (not visual but the car drives backwards instead of forward) or right wheel is forward and left is backwards. But this is a matter for another day or none at all well see.

I think that his wheels are still not making an arch which is fine for his chosen suspension kind (for lack of a better word) but thats hard to make out.
It sure looks great and i was going in that direction too use custom bones setup for better suspension animation aswell so i will definetly have another hard look at the second video ;D
That was a big helper and i wonder how i could have missed that one. :smiley:


The Wheel does indeed make an arch. I was a bit misguided because of the suspension type which constraints the axis of the wheel to be always at a 90 degree angle to the chassis. But it does indeed holds its exact distance to the suspension joint and therefore doesent stretch the mesh at all.

Do you have any further information / links how the bone setup is actually done for such a realworld suspension?
We tried fiddling around with maya and couldnt figure out how to constraint the bone/s to achieve that the wheel rotates around the suspension joint.
Or let me try to say it a diffrent way.
When the Wheel is going up and down it is bound to the suspension bone for so that the distance is not changing from suspension to wheel and so the wheel moves not only in z but in the y axis also.

I hope your not testing the Angle issue just for my sake!
Im certain i will find a way to do this in code actually i have the code already the real problem is the bloody setdefaultComponent which isnt working as i expected. Although it might be interesting for anybody who doesent wanna use coding at all so i think it wouldnt be for nothing if you can get it to work.

Thank you

No need for that i found the problem

after i had the component done and figured out that i had to cast in bp to get my comp to work with my functionality i tried to fix the steering and found out that the code wasent the problem ;D

I used Gamepad left stick and guess what…

Gamepad left stick is digital

Gamepad left x y is analog

So now i can shoot myself for going through all the trouble for nothing. Just kidding a walk through the park was enough.
But it was an interesting learning experience and now i can use my custom source code and debug bps. ;D

So in the end all is well ;D

Next part is the custom bone setup …

Yes, that’s what it was, maybe I shouldn’t have removed the image after all. I was having the same issue, and was printing the current steering axis value onto my hud to see what has happening, there was only -1 or 0 or 1, after a bit of frustration, I found the same fix. That was what I was trying to say, I got mixed up a bit on that question, and ended up forgetting how I fixed it. :slight_smile:

The custom bone setup in maya (or 3dsmax if you use it) is going to be the most difficult part, you will need to make the extra bones for each joint or moving part in the suspension, and then when you are skinning, you will need to set the bones to “LookAt” the next bone in the chassis until you reach the end. I use 3ds-max for my setups, and I can recommend a video that shows what I mean, I am not sure of the tools in maya, or whether it will work out ok, but have a look at this series:

It should give you a good idea on how and where to place the bones for an advanced suspension, he uses a few extra in the front and back to make the suspension move like you are looking for. Hope it is helpful, sorry it is not for maya, but should help out a bit! :slight_smile:

Thanks for the vid.

Do you have also a seethrough effect on your tires on higher rpm?
I got that effect especially during acceleration and deceleration. The wheels pivot should be perfect so that shouldnt be the problem.

Yes I do as well, I am not sure what is causing it, but it happens on all of the vehicles I have imported so I don’t think it is the pivot.

I have tried turning off motion blur, changing AA solutions (off, FXAA, TemporalAA), and many other settings while trying to narrow down the culprit but none of these seem to make any difference. I wish I knew what causes this, but have a feeling it is the rendering engine itself because you can get the same effect by making a cube (or any abject) spin at high speed around it’s center point. It would be great to hear epics take on this (if any dev’s are reading this??? :slight_smile: ).

The other issue you may come across in the future is Spring Arm Lag jitter. This occurs when you have a camera behind the vehicle attached by a SpringArm that is set to “Enable Camera Lag”. It works just fine at low speed, but once you get to a certain point the lag snaps back like it is at the end of an elastic band with the vehicle, it is a minor effect but still very noticeable at high speed. In order to get around this it is best to create your own system for camera lag in the vehicle BP (or code) that operates smoothly from a minimum to maximum value that are pre-determined, the built in SpringArm lag system seems to go beyond the maximum value for a few frames before snapping back to the maximum creating a jittering effect. I have implemented my own camera control that allows you to move the camera around the vehicle, and then transition back to being behind the vehicle when you let go of the thumbstick (on a gamepad), as well as a simple lag system that I will post up here later today in case you are interested.

Ok thats good to know that its not only my problem.

Did you rotate the cube also with the vehicle code or just rotate it over engine rotation functions?

Since its some sort of tire shader in use i thought it might be the nvidia shader that causes it but if it occurs with an normal editor rotation than we have to gets Epics attention somehow.
It’s not that visible with greater distance but who wanna restrict camera movement for hiding graphic problems?

Jittering i experienced more without the lag i get sick in minutes. For me the killer is the rotation that when the car rotates du to some crash or stunt the car is going out of focus because the cam inherets the rotation of the car instead of staying fixed with the arm and i havent found something that make the cam fixed to the springarm even if that is something i overlooked or missunderstood in the settings, i thought to go with some custom cam with some nice dampening in the near future also. Some kind of lag and backsnapping is wanted because for me it translates speed and acceleration.

It would be very nice of you to share your cam script. I think i can do that but u never know who is looking for something like it so if it dont takes too much of our time go ahead and i have to admit that im always happy when i get something that is working ;D
I have made one custom cam a few weeks ago for the ball project so that i could turn around the ball and adds forces to the ball respectivly from the camera view which worked out pretty nice.

Next big thing is HUD and lap/section funcionality. I saw part of the tutorial from Epic which is nice, but as he stated in the beginning he makes shortcuts for tutorial purposes and i had something with overlaps to check for directions in my head already and i wanna have some system for managing the track and its sections for better levelediting which will later be used also for AI if i go that way. (the follow the rabbit way with splines and sections for speeding an braking) But this will require a plugin and and that will be of course my first, so it will take some time.

Another thing i found out today is that i have to go with physics substepping, because i had major phys. issues when limiting the fps to 30, which i always use myself in editor so my graphics card stays cool and doesent make a sound. :smiley: , and the physics where going totally wonky or at least where completly diffrent from 60.
After some reading it became clear why and that i had to try substepping.

No problem!! Here is my custom camera setup which moves the camera on user input, then transitions back to behind the vehicle in a sweeping motion.

First image shows the “ResetCameraView” custom event, and what gets processed after the event is fired, second image shows how you would to fire-off the event. I have a similar setup for each of the actions that will need the camera to be reset after movements like steering, as well as ones for yaw/pitch movement from a controller (seen in image 2 & 3) Hope the images can help! :slight_smile:

Regarding the laps and HUD, download and look at how epic achieved this in the “Vehicle Game” on the marketplace (free). It has examples of checkpoints, fastest lap, and more, and for the hud they have a fully working speedometer that looks pretty cool also.

Just wanted to add one thing, I can not seem to find my BP containing the lag system, but it is really simple to make a basic setup. I had used the vehicles speed input into a Map Range (float) node, so at a given speed the camera distance gets pulled back at a pre-determined distance, then feeding that to the spring arm length, or camera location. You would want to call an event on tick for this to work.

The error tolerance values in the Nearly Equal nodes above are simply there so it does not continue to try and close the gap between 0 and 0.05, this value can be changed to whatever you need, but will keep the camera from trying to reset itself infinitely (eventually rounding errors will cause it to stop getting the delta of the two, but it is not necessary once the value is so close to 0). Then you will want to call the event whenever Steering, LookUp (Camera Pitch), and Look (Camera Yaw) events are fired.

EDIT: Also make sure the camera is set to NOT “Use Control Rotation”, however the Spring Arm IS set to “Use Control Rotation”, as well as Inherit Pitch, Yaw, Roll are all checked for this setup to work.

Also, I just downloaded ver 4.5 Preview off of the launcher, and there is a new “Advanced Vehicle” template that uses a car almost identical to Xenome’s UGV link I posted earlier, it has the advanced suspension with collision and physics constraints all set up, and could be a big help. Just launch the editor, and there is a new project type called Advanced Vehicle. :slight_smile:

Thank you so much DotCam

The cam script looks very nice and i will try it out later.
i dont use the launcher anymore so i missed that advanced vehicle template ;D

I included physx headers in my code and use some physx classes
like PxVehicleDrive4WRawInputData RawInputData;

That is workign fine so far as it compiles but the debugger in the texteditor doesent know them and therefore all is red marked.
Do you know how to tell the debugger to include these or is this something i have to live with?

Have a nice weekend

I have not incorporated it into a project before, but Rama made a wiki article on how to integrate the PhysX library into UE4 that should help you with that:

There isn’t really all that much to including the whole library, so it is probably best to do that instead of adding individual headers, will save you time in the future (if you plan to integrate more).

Hope that helps, and you have a great weekend too! :slight_smile:

I have a a little update for the visual problem with the wheels.

Its just Motion blur. You can turn that off or down in the camera settings.

Sadly theres no solution for disabling it for specific actors of meshes. There is a screenpercentage based disabling mechanism but since the wheels are so little its no use for cars.