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"

Changing WheeledVehicle TireType in Blueprints

This is something I've been struggling with for weeks now. Something as simple as just changing out the vehicle tire type within blueprints. From what I can understant this is not possible without somehow exposing the values of the vehicle wheel in blueprints.

I have found other posts asking the same question and from those I got some code that from my understanding would create a blueprint node that could be used for this, But currently I have no idea how to implement it.

This is the code I've found from another post, if anyone could explain to me how to implement this that'd be great.

  VehicleGame.Build.cs
          
          PrivateDependencyModuleNames.AddRange(
              new string[] {
                  "Slate",
                  "SlateCore",
                  "PhysX",
              }
          );
  
  
  
  
  class UVehicleMovementComponentBoosted4w
  
  VehicleMovementComponentBoosted4w.h
  
      /** Wheel Lat Stiff */
      UFUNCTION(BlueprintCallable, Category = "Wheel")
      void SetWheelLatStiff(int32 WheelIndex, float LatStiffValue, float LatStiffMaxLoad, float LongStiffValue, class UTireType* TireType);
  
      /** Wheel Friction*/
      UFUNCTION(BlueprintCallable, Category = "Wheel")
      void SetWheelFrictionScale(int32 WheelIndex, class UTireType* TireType);
  
      
  VehicleMovementComponentBoosted4w.cpp
      
  #if WITH_PHYSX
  #include "PxVehicleWheels.h"
  #endif //WITH_PHYSX
  
  
  void UVehicleMovementComponentBoosted4w::SetWheelLatStiff(int32 WheelIndex, float LatStiffValue, float LatStiffMaxLoad, float LongStiffValue, class UTireType* TireType)
  {
  
      if (WheelIndex >= 0 && LatStiffValue > 0.01 && LatStiffMaxLoad > 0.01 && LongStiffValue > 0.01 && Wheels.Num() > WheelIndex)
      {
          Wheels[WheelIndex]->LatStiffValue = LatStiffValue;
          Wheels[WheelIndex]->LatStiffMaxLoad = LatStiffMaxLoad;
          Wheels[WheelIndex]->LongStiffValue = LongStiffValue;
          Wheels[WheelIndex]->TireType = TireType;
  
          // init tire data
          // physx::PxVehicleTireData PTireData;
          physx::PxVehicleTireData PTireData;
          PTireData.mType = Wheels[WheelIndex]->TireType ? Wheels[WheelIndex]->TireType->GetTireTypeID() : GEngine->DefaultTireType->GetTireTypeID();
          PTireData.mLatStiffX = Wheels[WheelIndex]->LatStiffMaxLoad;
          PTireData.mLatStiffY = Wheels[WheelIndex]->LatStiffValue;
          PTireData.mLongitudinalStiffnessPerUnitGravity = Wheels[WheelIndex]->LongStiffValue;
          
          PVehicle->mWheelsSimData.setTireData(WheelIndex, PTireData);
      }
  
      
  }
  
  void UVehicleMovementComponentBoosted4w::SetWheelFrictionScale(int32 WheelIndex, class UTireType* TireType)
  {
      if (WheelIndex >= 0 && Wheels.Num() > WheelIndex)
      {
          Wheels[WheelIndex]->TireType = TireType;
          // init tire data
          // physx::PxVehicleTireData PTireData;
          physx::PxVehicleTireData PTireData;
          PTireData.mType = Wheels[WheelIndex]->TireType ? Wheels[WheelIndex]->TireType->GetTireTypeID() : GEngine->DefaultTireType->GetTireTypeID();
          PTireData.mLatStiffX = Wheels[WheelIndex]->LatStiffMaxLoad;
          PTireData.mLatStiffY = Wheels[WheelIndex]->LatStiffValue;
          PTireData.mLongitudinalStiffnessPerUnitGravity = Wheels[WheelIndex]->LongStiffValue;
  
          PVehicle->mWheelsSimData.setTireData(WheelIndex, PTireData);
      }
  }
Product Version: UE 4.12
Tags:
more ▼

asked Feb 12 '17 at 11:36 AM in C++ Programming

avatar image

TheHDFord
1

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

0 answers: sort voted first
Be the first one to answer this question
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