x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Wheels Properties realtime

How to change wheels properties of vehicle in realtime, I`ve tried to change array of wheels but nothink helps: Wheels.Reset(); for (int32 WheelIdx = 0; WheelIdx < WheelSetups.Num(); ++WheelIdx) { UVehicleWheel* Wheel = NewObject(this, WheelSetups[WheelIdx].WheelClass); check(Wheel); Wheel->MaxBrakeTorque = 0; Wheels.Add(Wheel); } for (int32 WheelIdx = 0; WheelIdx < Wheels.Num(); ++WheelIdx) { Wheels[WheelIdx]->Init(this, WheelIdx); }

Maybe I need something else?

Product Version: UE 4.10
Tags:
more ▼

asked Apr 27 '16 at 09:40 AM in C++ Programming

avatar image

Legolax
28 3 9 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I`ve found the soultion, set new parameter then recreate phyicsState:

 WheelSetups[0].WheelClass->GetDefaultObject<UVehicleWheel>()->MaxHandBrakeTorque = 0;
 WheelSetups[1].WheelClass->GetDefaultObject<UVehicleWheel>()->MaxHandBrakeTorque = 0;
 WheelSetups[2].WheelClass->GetDefaultObject<UVehicleWheel>()->MaxHandBrakeTorque = 0;
 WheelSetups[3].WheelClass->GetDefaultObject<UVehicleWheel>()->MaxHandBrakeTorque = 0;
 VehicleSetupTag++;
 RecreatePhysicsState();
 

more ▼

answered Apr 28 '16 at 08:32 AM

avatar image

Legolax
28 3 9 11

avatar image Cpt.Trips Jun 22 '16 at 01:53 AM

Where would I need to look to find the syntax for other wheel properties? i.e. I want to be able to change properties in the Wheel Class such as Radius or Suspension Raise / Drop etc. or just swap the entire Wheel Class.

This thread is the most promising I found, but I have no idea how to go about any of it.

avatar image Legolax Jun 22 '16 at 06:43 AM

If you use Visua Studio just click Ctrl+Space after "->" and select need parameter. If need, here is the list of Wheel properties and functions to use:

 class UStaticMesh*    CollisionMesh;
     bool bDontCreateShape;
     bool bAutoAdjustCollisionSize;
     FVector Offset;
     float ShapeRadius;
     float ShapeWidth;
     float Mass;
     float DampingRate;
     float SteerAngle;
     bool bAffectedByHandbrake;
     class UTireType* TireType;
     float LatStiffMaxLoad;
     float LatStiffValue;
     float LongStiffValue;
     float SuspensionForceOffset;
     float SuspensionMaxRaise;
     float SuspensionMaxDrop;
     float SuspensionNaturalFrequency;
     float SuspensionDampingRatio;
     float MaxBrakeTorque;
     float MaxHandBrakeTorque;
     class UWheeledVehicleMovementComponent* VehicleSim;
     int32 WheelIndex;
     float DebugLongSlip;
     float DebugLatSlip;
     float DebugNormalizedTireLoad;
     float DebugWheelTorque;
     float DebugLongForce;
     float DebugLatForce;
     FVector Location;
     FVector OldLocation;
     FVector Velocity;
     float GetSteerAngle();
     float GetRotationAngle();
     float GetSuspensionOffset();
     UPhysicalMaterial* GetContactSurfaceMaterial();
avatar image Cpt.Trips Jun 22 '16 at 11:32 AM

I'm working with the VehicleGame demo from the learning tab. Oddly, if I run your code from the second post (1 answer):

 GetVehicleMovement()->VehicleSetupTag++;
 GetVehicleMovement()->RecreatePhysicsState();

My car starts colliding with itself and just goes ballistic.

Edit: As for Code Suggestion/Ctrl+Space ("Intellisense" I guess) - I now ran "Generate VS Project Files" (rightclick on UE4 project file) and that part works finally (it compiled before, but not having code suggestion was just horrible).

avatar image Legolax Jun 23 '16 at 08:30 AM

Where do you use wheels recreating, and one additional moment when you use RecreatePhysicsState is recreates physics state, and the engine recallect all physics data and make new physcs state, as a result your car will lose all current physics force.

There only some parameters of car that you can change in realtime: EngineSetup, DifferentialSetup, TransmissionSetup, DragCoeficcient, mass, InertiaTensorScale, AckermannAccuracy, SteeringCurve and TorqueCurve, Inputs, DragArea

Speaking about wheels you could only change the frictionscale:

 VehicleMovement->Wheels[i]->TireType->SetFrictionScale(newfrictionScale);
 
avatar image Cpt.Trips Jun 23 '16 at 02:03 PM

only some parameters of car that you can change in realtime [...]. Speaking about wheels you could only change the frictionscale

I'm not sure I understand. Are you saying that most of the parameters you posted before (such as ShapeRadius; ShapeWidth etc.) can't be modified at all in realtime?

Shouldn't that work?

 GetVehicleMovement()->Wheels[0]->ShapeRadius = 10;

or (Not sure what the difference is):

 GetVehicleMovement()->WheelSetups[0].WheelClass->GetDefaultObject<UVehicleWheel>()->ShapeRadius = 85;

"Where do you use wheels recreating"

I am executing RecreatePhysicsState in the ABuggyPawn (a child of AWheeledVehicle class) inside an event triggered in the vehicle blueprint on key input (event is empty otherwise).

when you use RecreatePhysicsState is recreates physics state, [...] your car will lose all current physics force.

On execution (with or without change to any wheel parameters in the event), the car starts to jitter, shake and continuously gets bounced in the air (accompanied by collision sounds set up in the VehicleGame). It is a similar result to a car (or any other skeletal mesh) with auto-generated PhAT bodies.

avatar image Cpt.Trips Jun 24 '16 at 03:03 AM

After some fiddling around I made some progress on my journey to understand this stuff.

  1. I guess the difference between these two lines:

    GetVehicleMovement()->Wheels[0]->ShapeRadius = 10;

    GetVehicleMovement()->WheelSetups[0].WheelClass->GetDefaultObject()->ShapeRadius = 85;

Is the first being the current value and the second the configuration value applied on actor spawn. Changing the first doesn't do anything, while changing the other actually changes the data asset, as well as does this line:

 Wheels[0]->TireType->SetFrictionScale(1);

Frictionscale applies immediately at runtime, without the need to call recreate physics or setupVehicle() or anything, while ShapeRadius only applies after respawning the actor.

The problem though, as mentioned before: those changes apply to the actual data asset (if I go back to the editor, the data blueprints actually have changed). It's interesting, but not very useable, as it changes the actual config and not an instance of it.

Is there a documentation on this or some examples in general? Feel really lost on this.

Edit:

For now, as my prototype works with a single vehicle setup, I have a WheelData + TireType asset for each wheel and one custom DataTable with default configuration values. On BeginPlay the data from the DataTable is being applied to the MovementComponent and thus saved in the WheelData/TireType assets which I treat as runtime storage. For shape I unfortunately have to destroy and respawn the actor once.

In the end I am able to have each wheel use different friction, mass and radius. I guess if I wanted it to work with multiple vehicles, I'd have to dynamically allocate the WheelData/TireType.

Unfortunately with this setup I can only change wheel shape in a Garage Style environment, and wouldn't be able to simulate for example a flat or lost tire while driving.

avatar image Legolax Jun 24 '16 at 07:01 AM

Yeap, you have right, unfortunately there is no documentation about this, and we have to look into this by ourselves. Also, you could to look around SetupVehicle(), but it doesn`t work as needed. It also recreate your car and clear all its forces, but do not creat it after clearing.

avatar image Cpt.Trips Jun 24 '16 at 08:08 AM

As far as I tested, SetupVehicle() killed my inputs on the car, no idea why. It wouldn't react to inputs any more.

But if it worked correctly, should it apply changes instantly the same way I am doing now with destroying/respawning my actor?

Also, going back to RecreatePhysicsState() - what exactly should this accomplish?

Basically what I'm asking is - what is RecreatePhysicsState() and SetupVehicle() supposed to do?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question