for example I have a 3rd person template where I shoot a line out of the capsule, but it is the assignment I am concerned about
the DrawDebugLine() was put in to sanity check the vector.
I put in a timeline with X:[0,3] (3 seconds) and Y:[0,1]. I do end up lerp on the vector because getting a rotator, or quaternion isn’t as effective in Blueprints.
you can play around with the timeline, and remove the debug line, and the branch, you could even keep them for say an obstacle (entity, triggerBox, or secondary affect) that instantly forces gravity in a given direction; just be careful as too rapid of orientation switching can easily make players motion sick, or at the very least disoriented (unless that is your intent
)
I am seeing some misunderstanding of the FHitResult
- ImpactNormal: the vector that is opposite the force being applied to the object (think of this as the line pointing back along the instantaneous hit)
- Normal: the vector that is normal to the point of impact relative to the surface (think of this as the line pointing exactly away from the surface at the point of impact)
so given a cube, and a collision happening at 45 degrees to the surface, the ImpactNormal will be pointing back along that 45 degrees, and the Normal will be perpendicular to the surface.
to use that Normal vector as Gravity you need to take the negative of the vector (there is a Negate) because given the implementation you would want that “Normal” to be your character’s “UpVector”
____
when you have a transition lerp for the rotation, keep in mind that you may need to either disable the reassignment of your TargetGravity, or accept that your player may be able to switch the TargetGravity mid rotation, and end up in precarious positions (again dependent on your intent)
you could even introduce puzzles that disable the ability temporarily (while in TriggerBox disable gravity shift)
also be aware for the good or bad that this changing of the gravity frame only applies to the Character itself, and SetGravity only applies to Entities with a UCharacterMovementComponent, so to use it with say Pawns you will need to modify their MovementComponent to accomodate for gravity frames (which is not exposed to Blueprints, so you will need to go through C++)