How to use a Physics Volume to increase a vehicle's speed inside an area
Let me get this out of the way. I am VERY NEW to Unreal Engine and it's blueprint/volume mechanics, so make your explanations as easy to understand as possible, and if I explain something wrong, don't get mad.
So I'm making a Rainbow Road-like track with sideways parts and tight turns. I'm making a part in which you are launched into an upwards tunnel and fly up through it very fast and pop out the top. But since the tunnel is too steep to drive up regularly, I either need to increase the cars speed or make a car conveyer belt in order to complete this. And since I have no idea how to do this at all, I'm stumped. If anyone would be able to help me, that would be great!
P.S. Don't just give me the huge list of blueprint counterparts if it's not with a physics volume. I would recommend it should be. Thanks!
asked Aug 03 '17 at 07:54 PM in Blueprint Scripting
First go inside a your Car BP and add a Custom Event. Call it Boost (note you can add Inputs to this Function, whatever you need more later)
Create new Actor BP and Call it SpeedBoosterVolume. Add a Box Collision Component to it. Change Collision Settings to Overlap All and generate Overlap Events is set. Select your Box Component and add the Begin Overlap Event. Now from that Event pull from the Actor Pin and type Cast to [YourCarBPType]. Drag out of the Blue pin and type Boost (The Custom Event you created earlier). Hook the white wire up to the success. Drop a Couple of those Volumes into the Scene where you want the Boost to happen. Adjust the scale of the BoxComponent on each Instance to your liking.
Switch back to your Car BP and add a Print string to your Boost Event. Playtest and See if the String shows up if you enter the Trigger. If it does not double check your Collision Settings on the Car and the BoosterVolume!
Ok now we Enter a Area where you can Play around and I get very vague at this Point since it all depends on your Mechanics and how you Handle stuff to your Liking. In your Boost Event you can get the Movement Component and than its Updated Primitive Component. That is the thing you want to Add Force to or Manipulate the Linear Velocity. If you want to do it over a period of time you can Start a Timer (loop it or move anything else into tick, Branch aslong timer is Valid) you could also have a Stop Boost Event that you call the same way in your VolumeBP just with the End Overlap Event instead.
Now back to the Inputs of your Boost Event I mentioned earlier. You probably want things like Boost Strength and Force Direction comming from your BoostVolume (and other things, up to you) you can Click on your Boost Event and add the Inputs as you like. After you are done go back to your BoostVolume BP and you can See that the Boost Node there has the Inputs you setup. That enables you to send Data from your Volume to your Car.
So why or what you send as Input you might ask yourself now. Lets say you want to send a float that represent the Strength of the Boost over to your Car. Simply create a new Float Variable and Call it Strength, make sure you check "Editable" int the Variable Details. Give it some nice default value and plug it into your Boost Event. Now switch back to your Scene and Select one of your Volumes. If you look into the Details Panel you will See the Strength you can Adjust on each individual Volume. This gives you Configurability!
What about direction? Multiple ways. You could use something that already exists like the Cars/Volumes forward Vector or the Collision Normal from the Sweep Result. You can add something you can rotate in the Scene like a arrow Component and use its forward Vector. Or you could Calculate the direction in countless different ways. I Personaly would create a Vector Variable and make it "Editable" aswell as "Make 3D Widget" that will show you a Diamond shaped Widget if you Select a Volume in the Scene. You can drag it around and I like that it is a nice Visual Indicator where the Force direction will facing. Than you simply get this Vector subtract it from the Volume Location and Normalize the Result and you got a Unit scaled Direction Vector.
A tip on the side before you Normilze the Result you can get the Length of that Vector (distance away from your Volume Center) and use it for other Calculations =) but thats all Up to you and your Math Skills and the way you want to Handle things. I just showed you the Path to a nice Configurable and reusable System that you can adjust to your needs.
If you got Question or trouble feel free to Comment and attach some screenshots where you got Stuck.
Good Luck mate and sry for wall of text Engine is Compiling and Im a bit bored xD
answered Aug 03 '17 at 10:21 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here