Unreal - Move players's camera and hands at the same time - animation

I'm new to Unreal Engine and I want to make a First-Person game. I want my player to climb on top of a cube.
So I created a Camera animation, in order to see that the player is climbing (the camera goes up, then rotates a little, then goes forward). When the player is climbing the cube, I also want their hands to grasp the edge of the platform and push in the upward direction. I don't have a full skeleton, only hands like in the basic first-player example.
So basically, when the player presses space in front of a cube, I'd like to have my camera animation and my hand animation to play at the same time and to be synchronized.
Is there any animation class to do both in the same class ? Like a montage, or a sequence. When I go to animation montage, I can't find anything to import my camera animation.
When I create a new skeleton animation, there is no camera attached to the skeleton so I cannot move the camera and the hands in the same animation.
Thanks for your help!

Root Motion can do this. With Root Motion, you wouldn't animate the camera directly. Instead, you'd animate the character's root bone to move the character capsule (and thus camera). This would keep the camera and hands in sync and also allow you to implement your climb.
Stack Overflow isn't the best place to ask animation questions. I'd recommend one of the following instead:
Anim State (which also has a discord server)
UE4 Animation Forum

Related

Adding hats or skins to animated sprite in Unity

I am currently developing a 2D pixel art style platformer game in Unity. My main character is an ostrich, and I've made some running animation sprite sheets in a graphics editor. Now I want to be able to add some hats or glasses to the ostrich. The problem is that the ostrich head moves up and down in the animation, so I can't child a glasses or hat sprite and make it precisely follow the head. I have already tried animating the hat on it's own but it is firstly a lot of work, and secondly it smoothly transitions through the positions, hence not fitting to the sprite every frame.
To make myself clear, I want to make a sprite follow a certain position on a spritesheet animated character precisely to the pixel.
How could I achieve this?
Cheers,
Alex
Comment
One option would be to animate the ostrich inside Unity, so that each body part you animate is it's own object. That way you could then add e.g. a hat as the child object of the head. But since you have already made pixel animations outside Unity, this is of course not an ideal solution. It also sounds a bit like this is what you mean with saying "child a glasses or hat sprite", but I wasn't sure if that was in the pixel part of it or not.
Answer
If you animate the head in Unity, that would make the animation for all things you then attach later on, hates, glasses etc.

How to change rigs spine rotation in unity3d, using camera rotation?

I have a rigged 3d model of a person with animations that i made. It is a player model in a first person shooter. I want this model to "bow", when looking down or do the opposite, when looking up. To achieve this, i decided, instead of making an animation for each degree the player might decide looking at, to rotate models spine, depending on the angle of the camera. In scene view, i can easily change rotation value and get the results i want, however, when game is running, those parameters seem to be "locked" and no matter what script i tried, i cant seem to change the rotation value. I figured, perhaps, when animation is playing, i cant change things it effects, so made a body mask to excluded torso from animations and spines rotation was still locked away from me. Is there a way to rotate models spine, when its doing its normal, lets say, idle, animation? is there actually another easy way to achieve this?
You have to update in LateUpdate(). Unity's animator does it's changes to the transform in Update(). By doing it in LateUpdate() it will be handled after the animation has made it's changes.

Unity2D - Player relative animation positioning

I'm making a 2D platformer and I've come across a really annoying problem where if I move my player character GameObject to another location on the scene, my player becomes stuck and the game spazzes out, jumping from the players original location and the position I moved it to.
My player character is made up of many parts, each a separate GameObject. I know the problem is definitely in my animation, because if I disable the animator component, the problem goes away, just I don't have my animations anymore. I believe the problem may be in the player character's Idle Animation and it's position property. There is no script attached where his starting location is hard coded.
How can I make the child Gameobjects move relative to the parent Player GameObject? I cannot move the player in the scene from its original location without the game glitching up.
Here are some screenshots
[Player and it's parts in Hierarchy]http://i67.tinypic.com/bdlc1j.png
[Idle Animation]http://i64.tinypic.com/2gtp99x.png
[Player's original Location, he works if starting here] http://i66.tinypic.com/261jb6c.png
[Player is Moved, game bugs out] http://i67.tinypic.com/292a2c3.png
Try to disable "Apply Root Motion" flag in the Animator component.
The problem should be related to the fact that the animation changes the position values
My guess is that you have animated the different parts by moving then around in the editor and recording that. This meas that the animation is keeping track of the original position at which you did the animation. Try deleting those parts from the animation.
I couldn't fix the spazzy-jittering problem that occurs when I move the player character to another position on the scene, but I did find a way around it. The problem definitely lied within the Animator component and the gameObject's Rigidbody2d.
Instead of moving the player to another position, I instead made a 'Spawn Point' which the player starts from when first playing the scene, and that was able to be moved freely around. Pretty much:
void start(){
transform.position = spawnPoint.transform.position;
}

How to collide .fbx animation in Unity

I am new to unity. I have two animation in .fbx format.They can move..Now i want when both will collide with each other a sound will produce.Is there any idea how i will do this.Thanks in advance
I think you need to read about how Physics work, and then how Trigger-Events and Colission detection is handled.
Read this here, and this. The first one gives you insight on how the Unity engine works. The latter provides a video tutorial on how to do Collision Detection.
If you don't want to do that and just want the code, I found this on a quick Google:
var crashSound : AudioClip; // set this to your sound in the inspector function
OnCollisionEnter (collision : Collision) {
// next line requires an AudioSource component on this gameobject5.
audio.PlayOneShot(crashSound);
}
You can add a MeshCollider to the fbx meshes. Anyway, this is not a good idea because this will cause performance issues.
You can create an empty gameobject for each character, and add to them: the fbx animation and a simple collider (some cube, sphere, capsule, etc). Then, when you use a script for them, you attach it to the parent object and from there you handle the whole thing.
If you want that the collider moves from specific places from the animation (Like the punch movement, or a kick),then you can ask to your 3D animator/modeler to add a simple mesh on that points. For example, a sphere on one punch, which will move with the animation. Then, in Unity, you will hide the mesh of the sphere but add a mesh collider to it. :)
Hope it helps!
Most of the time, if you apply an animation to an object then you'll loose the physics reaction. Don't trust me? See here: http://www.youtube.com/watch?v=oINKQUJZc1Q
Obviously, animation are not part of Unity physics. Think about it... Unity physics decide position and rotation of objects accordingly to Newton and friends laws. How do you think these laws can accord to a keyframe arbitrary animation? They can't: hence the crazy results you get when you try.
How to solve it? Use Unity physics also for animation: learn to master rigidbody.AddForce and all the other stuff described here.
You may always want to keep the physics and the animation separated. That's how you get out of trouble.
If you really want to know: here's my personal experience on how to mediate physics with animation.
Sometimes, even binding a simple parameter to the physics and another
to an animation (or a script which mediates user input) may result in
catastrophic results. I've made a starship: rotation controller by
user mouse (by flagging "block rigidbody rotation"), direction and
speed by physics. It was inside a box collider. Imagine what happens
if a cube, orientated by a few degrees angles, meets a flat ground: it
should fall and rotate until one of the faces lays completely on the
ground. This was impossible, as I blocked any physics interaction with
the rotation of the body: as a result the box wanted to get flat on
the ground but couldn't. This tension eventually made it move forward
forever: something impossible in real world. To mediate this error,
I've made the "block rotation" parameter change dynamically according
to the user input: as the ship is moving the rotation is controlled by
the user but as soon as the user stop controlling the ship the
rotation parameter is given back to the physics engine. Another
solution would be to cast a ray down the collider, check if the ground
is near and avoid collisions if the ship is not moving (this is how
the banshee in Halo Combat Evolved is controlled, I think). When
playing videogames, always have a look at how your user input is
mediated into the physics engine: you may discover things which a
normal player normally wouldn't notice.

Implementing terrains in XNA similar to Battle Zone (1980)

I am developing a 3D game for Windows Phone that includes terrains and volcanoes at infinite distance similar to Battle Zone (1980) by Atari Inc. The player can never touch the terrains no matter how far player drives. Currently, to implement this I am mapping a 2D texture inside the wall of cylinder. The cylinder is also moving with the player so that the player can never reach terrains. I am not sure whether this is a good method to implement terrains as I am facing problems like distortion of texture when mapping it on the wall of cylinder.
Please suggest me methods to implement a view of terrains in XNA similar to Battle Zone?
normally instead of cylinder developers use box (so-called SkyBox)
It has less polygons and in general less distortion (could be some at edges)
To make it look more real some devs like Valve use off-screen render in first pass that include skybox + some distant models with low details and moving cloud sprites or textured ring with alpha. Both points of view are synchronised (main camera and off-screen camera) then (without clearing colour buffer) they render final scene on top. Thanks to that far building will move a bit and scene surrounding will look less plain. To avoid z-buffer cleaning between passes they simply doing first pass under the floor(literally) of the scene of main pass.

Resources