How To Keep A Particle From Rotating To The Camera Unreal Engine
I've been experimenting with AI Controllers and my Unreal Guys walking towards random locations in the game earth. Equally such I needed a way for them to turn smoothly towards said random locations before they starting to walk. Thankfully I found out most the Notice Wait At Rotation node. It was exactly the missing piece to this brainteaser.
Hither's how I made my Unreal Guys plow towards a new location:
This is a custom event on my grapheme. It's called from my custom Behaviour Tree Node, passing in a new Vector called New Location. Kickoff I'll grab my capsule component'due south World Location and use the Detect Await At Rotation node to get where (or what) my grapheme should exist looking (at). This node needs the new location to give united states a Rotation value. I'll break that struct and access the Z rotation.
I'll also grab my current World Rotation and find out where my character is currently looking at. Over again the Z rotation is all I need to continue. Nosotros need to observe a mode to interpolate betwixt these 2 values, and then continuously update the Z rotation until we reach the new value. At that betoken, nosotros're looking towards where nosotros're going to walk side by side.
To interpolate these values, I'one thousand using a combination of Timeline and Lerp Node. The Timeline volition requite us a bladder value between 0 and 1 interpolated over one second. When plugged into the Lerp Node, information technology'll interpolate betwixt two values of the same kind and give out the interpolated value (in our case, the Z rotation). We'll use that to make ourselves a new Rotator, which will and then update our current World Rotation.
Lerp nodes are very flexible. It stands to reason that the breaking/making rotations could be avoided, since the Lerp tin deal with blending 2 rotators. I've tried this too, but it leads to weird results on the characters. I'd advise against it. Information technology would make for a neater Design though – check it out:
On a personal note, I was quite surprised that with my express noesis of Unreal Engine, I managed to work out this rather complex equation. I'm showtime to understand how Unreal Engine thinks 🥰
If you savor my content, please consider supporting me on Ko-fi. In return you can browse this whole site witout any pesky ads! More than details here.
Source: https://www.versluis.com/2020/10/how-to-rotate-an-actor-towards-a-location-in-unreal-engine/
Posted by: reedvortunfir88.blogspot.com
0 Response to "How To Keep A Particle From Rotating To The Camera Unreal Engine"
Post a Comment