EDIT:
I fixed the or to be more exact i didnt understand the wiki entry from Rama (thanks you so much Rama)
https://wiki.unrealengine.com/Custom_Character_Movement_Component
.cpp
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 when progress is made
END EDIT.
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>(, 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 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 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 isnt possible right now due to some bug … the question is will i have side 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 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.
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 all one has to do is using a wheel with a bone and attach it to the wheel bone.
Beware 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 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 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 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 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 cars wont miss 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
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