- Home /
Force Constant Velocity On Game Object?
Hello, I am having trouble with my game. My game is an avoid the objects game and the objects are constantly falling down. But due to Physics they all gain speed falling down making my game near impossible. I am trying to figure out how to make it so that the objects all have constant velocity and then freeze when they hit the ground/another object. My game is 2D and is for the Android. The objects are squares. All help is appreciated.
Have you changed the mass and the gravity scale of the game objects make it same for all the falling game objects
If I ware you, I wont use the physic engine to drop the object. I will add all falling object to a list and then update the position of all object in the list every frame. this is easier to control for me.
I have done that, although since some objects spawn randomly high up they gain speed co$$anonymous$$g down.
Do you untick the "use gravity" check in every falling object?
Answer by JustinC · Feb 06, 2015 at 07:27 AM
I am not to familiar with 2d games, but you can turn the gravity off on the rigidBody, and use rigidbody.AddForce(-Vector2.up * speed) to make it "fall" and use a OnTriggerEnter funtion to stop the addforce, or a raycast if you want it to stop at a certain range above an object.
Answer by AndresBarrera · Feb 06, 2015 at 08:05 AM
If you are using rigidbodies, turn on the 'isKinematic' property, and turn off the gravity for each one of them. Then move them yourself.
float speed = xxxx;//the value you want
Vector3 direction = xxxxxx;//The direction you want to move. Normalized
void Update
{
this.transform.position += direction * speed * Time.deltaTime;
}
Answer by SUPPEAR · Feb 06, 2015 at 08:26 PM
I don't think you completely realize what I want to happen, I have updated the positions manually but they all go down to a certain point. I want the objects to completely stop when it hits the floor or is stacked on top of another object.
Answer by manihatelax3 · Nov 15, 2021 at 06:51 AM
Set the velocity of the object to zero when collided
Your answer

Follow this Question
Related Questions
Make object move randomly 2D 2 Answers
Making Object Clickable(Need Guidance ASAP) 2 Answers
Destroy Object On Touch? 2D 1 Answer
Destroy Object On Touch? 4 Answers
Cannot touch cloned prefabs 0 Answers