Gradually decreasing the velocity of an object through animation in Unity - unity3d

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

Related

How to get rid of acceleration during bouncing ? (unity 2D)

I don't know if this is the correct therm, but I want to get rid of any kind of forces that could modify the speed of my object. Let me explain : the game is 2D top-down view and the character fires a bullet that bounces x amount of time, WITH CONSTANT SPEED. Everything works fine, but when the bullet bounces fast and many times, its speed increases.
Also, second problem: I have a rotating object and when the bullet hits it, its speed increases (which makes sense, but I would like to know if there is a way to delete this effect) .
I would like to know if there is a way to solve my issues.
You need to check the material of the object for your first question (https://docs.unity3d.com/Manual/class-PhysicMaterial.html) you need to set Bounciness to 1 so it will maintain dame speed. If you set it to 0 there will be no bounce and probably you have a value bigger than 1 and so it's increasing.
In the second case it's all about the forces involving. The object bouncing on the rotating one is adding a force to that one. If you want to keep the second one with same rotation you could rotate it with a transform.Rotate and remove a Rigidbody or set it to static

Unity - Animation Loops?

I am using an FBX 3D object file as a game object in my project which have further sub assemblies. Now i want to animate a part of the assembly.
I followed this process:
Select the part which I want to animate.
In the animation panel create one animation.
Add property > transform > position
Using pivot, i move that part to the location where I want to animate.
Challenges
Animate in loop. Moreover if I Select animation file, it does not show Wrap mode
( 1. I don't want any loops in my animation, even after deselecting loop-time it does loop. - I dont know why?
It is animating in reverse. suppose if the object needs to go from position x:3 to position x:8 but it goes from position x:8 to position x:3
the above point happens in loop. just like a ping pong)
Animates in reverse.
I take the whole animation as one loop i.e Part comes out of assembly and goes back and repeating for infinite time.
I want to stop the animation till the point it comes out.
Any help will be appreciated

JavaFX - Creating basic jumping mechanic

I've been looking for awhile now for someone who had created a good example of making good physics in JavaFX, or even just a 'basic jumping mechanic' as the title says. I can't really find any information on it and I'm not really sure how to implement the idea.
All I want is a basic example, or just an explanation, or even just a point in the direction of what element of JFX I'm going to use.
Any help is appreciated.
Thanks
I'm assuming you already have some sort of game loop that ticks 60 times a second such as the AnimationTimer. If you want the jump height to be something like 200 pixels, you need to set and objects y-velocity (velocity is added to the objects location every tick) to a large negative number (as the object is moving upwards) and add a smaller amount every tick to this velocity until it hits zero, (this will be the top of the jump) and then keep adding this value to the y-velocity until it reaches the ground or collides with something. (This value will be your gravity constant)
In essence, you need to set the y-velocity to a high value then take away small increments every tick to slow the jump until the y-velocity hits 0, then begin adding the gravity constant again until the object hits the ground, hope this helps :)

Changing the speed at which an object drops when affected by gravity.(SpriteKit)

I have an object that needs to fall down the scene when the game starts. When the player taps the screen the object moves back to the top of the scene. In order to make the object fall I set it to be affected by gravity. This works fine but the problem is the object falls down the screen to fast. Can I set the speed at which the object falls do to gravity to a different speed. If so how do I do this.
You can reduce the gravity of the physicsWorld. Another option is to apply a force in the opposite direction to each object. If the gravity is -9.8 in the y axis, you could apply a force from +0-9.8 in the y axis to slow the object down.
EDIT: Changing the mass does not affect the speed.

How to make object fall in line with the target when applying wind effect?

I am making a paper toss kind of game in Unity3d. I am implementing wind effect using constant force. I wanted to know how to make object fall in line with the target ie, if the object gets over the target, it should go in or fall in line with the target, not go behind or in front of the target. At present when I swipe applying a constant force, for different angles of swipe the distance moved by the object differs. Help would be much appreciated.
In FixedUpdate, use Physics.Raycast to check to see if the object is over the target. If so, set the x and z values of rigidbody.velocity to be zero (assuming y is the up/down axis in your game world) and disable the ConstantForce component (i.e. gameObject.GetComponent<ConstantForce>().enabled = false). Note that this won't be most realistic of movements, as it will seem like the object suddenly moves straight down when it goes over the target -- but it sounds like that's what you want.