Character with animation track and virtual camera move back to it's original position when changing animations with Timeline, Fix/Work around? - unity3d

In the first screenshot the Timeline the start. When I hit play or dragging the time slider all 3 characters the two soldiers and the female in the middle will start walking. When they get to the HumanoidIdle animation part the two soldiers will change to idle on the last(current) position they are but the female the one in the middle that also the virtual cameras to follow will change it's her position back to the original start position.
I saw this work around but I can't figure how to do it and what should I do. Take empty new GameObject and do what ? : "The only workaround I can give you right now is to have a parent gameobject that would be used to record the position and keep the Humanoid object for animation clips."
Why she move back when changing to idle ?
You can see the problem here on the second screenshot:
In the third screenshot the Navi vcam (first virtual camera) settings. I'm following the female character the one in the middle:
On the last screenshot the Navi vcam (1) This is the second virtual camera with this one I'm following and Look At the female character in the middle:
I can't figure out why when it's changing the animations from walk to idle the character with the virtual camera/s change it's own position back to the start original position and not staying in the last/current position like the soldiers?

Related

Why when creating a new transition back to humanoidwalk state animation the character change position and not keep walking from where he is?

After playing the animation in the state Catwalk Walk Turn 180 Wide R 0 the transition back to the HumanoidWalk but instead of continue walking from the current position the character is kid of sliding to the starting original position he started walking the first time and continue walking from there.
Instead i want that when the animation in the state Catwalk Walk Turn 180 Wide R 0 finished play that the character will continue walking from the current position.
Screenshot of the back transition to the HumanoidWalk state :

Gradually decreasing the velocity of an object through animation in Unity

I need to create 2 animations,
one is of an object going from point A to point B at a constant velocity.
the other is of an object starting from point A but with a gradually decreasing velocity as it reaches point B until it comes to a stop.
I tried decreasing the animation speed every second to achieve this result with no luck.
Any ideas?
As you may have noticed when you work with animation in Unity there is no such thing as changing the velocity of an object. What you need to do is give your object an Animator and create a new Animation.
Then on the animation timeline press the red dot (record button) and then place your object on point A.
Next, on the time line you want to select the exact second that you want your object to come to a stop and after that move the object on point B.
Now, the more seconds there are in between the 2 keys, the more time it's going to take for the object to travel.
To make it gradually slower instead of it just travelling slowly:
On the animation panel you will see 2 tabs. Dopesheet and Curves. Hit Curves and play around with them till you have a satisfing result.
Documentation on using Curves

IsOverlappingComponent works only when the character moves?

I have this third person character blueprint in which I'm trying to hide the character mesh if the CameraVisibilitySphere component overlaps the character. It actually works, but only if the character moves.
If simply I move the character close to an object, rotate the camera so that it collides with the object and gets closer to the character, the mesh won't disappear. But if I just move the character a bit, no matter in what direction and so that the sphere still overlaps with the character, Is Overlapping Component returns true as it should and the mesh is gone.
When the mesh is not visible, without moving the character, and I rotate the camera so that the visibility sphere doesn't overlap anymore, nothing happens. If then I move the character, the mesh reappears.
I tried using OnComponentBegin/EndOverlap and I've also coded it, but nothing changes, it shows the same behaviour.
The code I set the sphere with is this:
CameraVisibilitySphere = CreateDefaultSubobject<USphereComponent>(TEXT("CameraVisibilitySphere"));
CameraVisibilitySphere->SetupAttachment(FollowCamera);
CameraVisibilitySphere->SetSphereRadius(12.0f);
CameraVisibilitySphere->SetCollisionProfileName(TEXT("Actor"));
CameraVisibilitySphere->bGenerateOverlapEvents = true;
CameraVisibilitySphere->OnComponentBeginOverlap.AddDynamic(this, &ABatteryCollectorCharacter::OnCharacterBeginOverlap);
CameraVisibilitySphere->OnComponentEndOverlap.AddDynamic(this, &ABatteryCollectorCharacter::OnCharacterEndOverlap);
BTW the character's capsule is set to generate overlap events and to overlap with the camera.
What should I do to make this work? And, most importantly, do overlap events get called on child components of the same actor?
I'm new to Unreal, so I still don't know the environment very well.
Overlaps created in the parent are inherited in the child. You might try getting your Camera and do a MultiLineTraceByChannel, break the hit result and cast the hit actor to your character, then in your character, fire off the code to hide the actor with a custom event.

Using mouse position to control character animation

I would like to set up an animation for my character and have the progression through the animation be controlled by the mouse movement.
E.g. the character starts in a rest state - the first frame of the animation - as the mouse moves through the x axis, it plays the animation forward in a linear relationship with the movement of the mouse. If you stop, the animation halts at that point and if you move backwards, the animation is reversed.
Like scrubbing in a video editor except instead of a vide, it's a character animation.
I'm guessing this is eminently doable but will it be relatively trivial to do within Blueprints or am I better off using C++?
SquidInker!
I'm two years late here, but for the sake of Google posterity here is the Blueprint solution as of engine 4.17.0:
In your Animation Blueprint, right-click on the node for the animation asset in question, and select "convert to single frame animation"
Your node will now have an "explicit time" input pin, which you can parameterize as you like to scrub through your animation:

Need Unity character controller to make sharp 90 degree turns and not slide when turning

I'm using the first person controller for my characters movement. On a left arrow keypress, I'd like the character to instantly rotate 90 degrees and keep moving forward. Currently, when I hit the arrow key, the character makes the sharp 90 degree turn, but the forward momentum the character previously had takes a second to wear off so the character ends up sliding in the direction he was previously moving a short bit.
The closest example I can think of to visually explain what I'm trying to do is how the character turns sharp in Temple Run. How my game is currently working, if I had the character on a ledge make a sharp left turn, he'd likely keep the original momentum and slide off the edge right after he turns.
Since my character is running on the x/z axis, I'm wondering if there would just be some way to maybe swap the directional velocity/momentum? The speed the character had on the x axis would instantly be switched to the z when it turns and the other would be set to zero. I'm obviously open to any solution that accomplishes what I'm looking for.
I dug into the CharacterMotor class in the first person controller, but have yet to find what part I can tweak to accomplish this.
I'd greatly appreciate any help.
Thank you.
You can try to stop the velocity of the Rigidbody before turning.
this.rigidbody.velocity = Vector3.zero;
this.rigidbody.angularVelocity = Vector3.zero;
If you want the object to continue like it did, you can try playing around with it by saving the current velocity in a variable, setting it to 0, rotate it and then putting back the old velocity (still forward).
If it works with global vectors (so from the point of view of the world, not the object), then you can try negativing the velocity, actually causing it to go 'backwards'. I can't test it for now but either way I think you need to set the velocity to zero first before turning the character.