Questions tagged [rigidbody]

In game development, a rigidbody is usually referred to anything that is affected by physics.

Filter by
Sorted by
Tagged with
4 votes
2 answers
1k views

Nestling into contact with a group of physics objects without exerting forces on them

I'm making a pool game, and would like the circle (imaginary) to be in contact with the table and balls, and to fit perfectly as a ball would. Now I thought I would use Rigidbody and lerp the ...
John Smith's user avatar
  • 1,255
5 votes
3 answers
22k views

How to check if grounded with rigidbody

Does anyone have a better way to make an object with a rigidbody check for ground and then jump, right now I wrote a script where a raycast is cast downwards and it checks for distance but then I ...
John Smith's user avatar
  • 1,255
0 votes
2 answers
2k views

Dragging a Rigidbody2D without passing through obstacles

I have this body of code written for an object that needs to be an obstacle and another object that is draggable. I have colliders on both and a kinematic rigidbody on the draggable object, but the ...
MContributor's user avatar
1 vote
3 answers
2k views

How can I create a dice toss that results in a specific value?

I am trying to create a 3D dice for a game. Normal dice has been created by setting cube for dice with Rigidbody and apply force to throw a dice. Now the problem is, the user wants to give a value 1 -...
Manoj Balaji M's user avatar
1 vote
2 answers
8k views

Move rigidbody using WASD keys but rotate it based on camera/mouse movement

I am very new to unity and my scripts are based on some scripts found on the web. I want to make a first person view so the camera is attached to my rigidbodys head. Then i want to move my rigidbody ...
MBrain's user avatar
  • 75
0 votes
1 answer
1k views

Momentum-wise accurate player controls in Unity regarding collisions

First post here. So I am a newbie to Unity and am willing to create a general character controller script to base my future characters. I understand a character's mechanics are pretty design (UX) ...
cbugk's user avatar
  • 103
0 votes
1 answer
2k views

Rotate Rigidbody to face away from camera with AddTorque

I have a camera that rotates around an object with "Look At" . I want the object to rotate to face the direction the camera is pointing (Camera.main.transform.forward) using AddTorque, but I can't ...
Daniele Pappalardo's user avatar
0 votes
2 answers
865 views

Unity : how to Rotate GameObject back to Indentity position?

Hello i m trying to rotate my object smoothly over MouseButtonDown and rotate to identity position on MouseButtonUp and this code rotate my GameObject smoothly but it won't come back to identity ...
Kartik Shah's user avatar
8 votes
3 answers
5k views

How to move the player while also allowing forces to affect it

For now, that's how I move the player: rb.velocity = Vector2.right * input.x; And I affect him a force while he is damaged by an entity: ...
Basea Basilia's user avatar
3 votes
3 answers
5k views

implementing magnet like system in unity

I'm implementing magnet like behavior in unity3d. the red object have a script that add force to it toward a blue object. to do that i use this code: ...
dev-masih's user avatar
  • 164
1 vote
1 answer
1k views

How to check if NPCs are on ground or not?

I'm using Unity Engine. I see the common way to check if player is on ground is shooting a Raycast: How to solve the ground check problem? How to check if grounded with rigidbody I have a simple ...
123iamking's user avatar
1 vote
2 answers
153 views

Changing speed of an object

Is there a way of changing speed of an object at certain time? I want to change my speed to my initial speed after colliding with any object. I have already added bounce Physics to my colliding ...
Mazim Arif's user avatar
0 votes
0 answers
389 views

How to make two connected rigidbodies pull each other?

I'm making a game in Unity where a ship can connect to a rock in space, and drag it. Both are Rigidbody2D. I want the ship to be affected by the rock like this: If I drag the rock, then stop the ship,...
BlueGooGames's user avatar
0 votes
2 answers
179 views

Issue giving object player's hand position

I'm trying to put an object (for example a sword) in my player's hand. To do so i set the player's hand transform as the object's parent, in order to have the same movement for the object and the hand....
Rémi Hirtz's user avatar