Questions tagged [rigidbody]

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

Filter by
Sorted by
Tagged with
8
votes
3answers
4k 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: ...
4
votes
3answers
16k 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 ...
4
votes
2answers
2k views

Unity Ragdoll Colliders don't collide

I have a humanoid character with Ragdoll setup in Unity. However the box/capsule colliders on the various parts of the body don't collide with other static geometry. They do collide with the ground ...
4
votes
1answer
1k views

How do I add a smooth force my player's rigid body, to make them jump?

I am trying to add force to the player's rigidbody, when the screen is held. I've written the following code: ...
4
votes
0answers
789 views

Unity & Alternatives to non-convex collider + non-kinematic rigidbody

I am working on a voxel game, where everything is one or more chunks of voxels (16x16x16). As voxels can be destroyed the chunk and collision area changes and can of course become non convex. So to ...
4
votes
1answer
205 views

Set input relative to map rotation?

I'm trying to figure out how I can make the input which looks like this : ...
3
votes
2answers
2k views

Using collision.contacts to determine if on a floor

I'm trying to make my own first-person character (because I get lost in the sea that is Unity's FP character script), and am trying to make it so it detects when it is standing on a floor. I tried ...
3
votes
4answers
5k views

How to disable gravity for a RigidBody moving on a slope?

I created a script that handles movement for my player (moving around, going down and up slopes). However, since I'm using a RigidBody not a CharacterController when I go up slope and stop on the ...
3
votes
1answer
766 views

'Ball.rigidbody' hides inherited member 'Component.Rigidbody'

I have some understanding of c# and I am new to unity. I am currently making a 3D project which use the Rigidbody component on the ball object. When I use following code: ...
3
votes
1answer
620 views

Jumping onto higher ground Collider issues

What's the general solution to the following character animation problem (I'm using Unity)? You have a character with a capsule collider and a jump animation that allows you to jump onto higher ...
3
votes
1answer
3k views

Limiting x and y movement so you can't go off camera

So I want to make an on rails shooter like that of Star-Fox in the Unity engine. What I would like to do is limit the ship from moving off the screen. You move along the X and Y axis so i wont have to ...
3
votes
0answers
180 views

Unity - kinematic rigidbody character calling OnCollisionEnter and OnCollsionExit on every frame for specific collisions

I'm encountering an issue with my character collider behavior. I have several elements that are relevant to this issue: a "character" gameobject (capsule mesh), that is assigned with a kinematic ...
3
votes
0answers
384 views

Add Rigidbody and MeshCollider at runtime : is it a bad practice?

Good day. To simulate an explosion of a vheicle, I decided to do this: When I need to explode veichle , at runtime, i add rigidibody for every single part of veichle (5-10 part: door, wheel, hood ...
2
votes
2answers
1k views

How to count rotations or spins when using addtorque?

I have a rigidbody and use 4 keys to addtorque in 4 different directions: W adds torque positively along the X axis (pitch forward) S adds torque negatively along the X axis (pitch backward) A adds ...
2
votes
2answers
553 views

Unity c#: How to slow down rotation over time?

I am making a space combat game, in which the player can press q and e to roll their ship. I did this by adding torque to the rigid body when the player press q or e. However, after they do so, they ...
2
votes
3answers
772 views

OnTriggerEnter doesn't detect collision until at least one of the two colliders move

I'm having trouble coding a melee attack script. I've set up an attack hitbox that toggles enabled/disabled whenever you press a button (The hitbox itself doesn't move, it just blinks in and out) ...
2
votes
3answers
3k 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: ...
2
votes
1answer
847 views

Why does applying force to a game object apply force to children, as well?

I have a script on my player to move. I do not have root motion applied because, root motion does not work perfectly so I'm manually adding velocity to the player. The player is holding a ball and ...
2
votes
1answer
3k views

Unity tilemap collider not colliding with rigidbody

In the wireframe you can see the tilemap collider for this hill. The red circle falls right through however. The circle has a 2D rigidbody attached. Everything is on the Default sorting layer and on ...
2
votes
1answer
4k views

Unity's CharacterController vs. Rigidbody with Collider

With a few friends I started to make a 3D game in the style of the old platformers à la Super Mario 64 / Spyro / Banjo Kazooie. So now we are thinking about the controls and how to do them. There ...
2
votes
3answers
4k views

Unity, rb.MovePosition and transform.Rotate at the same time

I can't figure out why my object can't move and turn at the same time. ...
2
votes
1answer
7k views

Proper way to set a RigidBody's maximum velocity

I am trying to gradually accelerate a GameObject with a RigidBody attached until it reaches a maximum velocity, at which point it becomes unable to gain any more velocity. I know I can simply reset ...
2
votes
1answer
3k views

Problem when trying to use rb.MoveRotation in Unity

OK so I learned that rb.MoveRotation is different from rb.transform.Rotate(). But I am having trouble using it and hoping you can help me. I usually use transform.translate(Vector3.forward) (after ...
2
votes
1answer
387 views

How to replicate Unity's Rigidbody.AddForceAtPosition in C++?

I am trying to replicate the function Rigidbody.AddForceAtPosition of Unity in C++, it means, to apply force to a body offset from its center. How could I achieve that in C++?
2
votes
1answer
588 views

How can I rotate RigidBody and not violate physics?

I'm trying to create a game that we have a falling ball and an spinning object that spin based on user mouse position. user should rotate the object and hit the ball on time to throw the ball into sky....
2
votes
1answer
1k views

How to add constant force to player with sperical gravity planet.?

I have a planet and character. My player move perfect around planet with pressing key like 'w','s','a and 'D'. I want to move my player on every frame with same force around sphere. I try plane ...
2
votes
1answer
398 views

Unity rigidbody exhibits a premature max speed

In effort to build a racing simulator, I have been working on a working model for the pistons in the engine, and have come to a bit of a stand still. I have gone through extensive testing, through ...
2
votes
2answers
379 views

Rigidbody2D Circular Orbiting

I am trying to create a basic solar system in 2D. All space objects has CircleCollider2D on them (which are required for raycasting in another script). Currently planets are childs of stars, and ...
2
votes
1answer
3k views

Two 2D objects in Unity aren't colliding together

In Unity 5, I have a player shooting a projectile in aim to hit a boss, and inflict damage upon contact with the projectile. Though for some reason, the projectile and boss aren't colliding with each ...
2
votes
2answers
553 views

Unity Engine 2D rigidbody inaccurate jumping whilst on a platform that moves downwards

I'm currently hard at work on a little platformer in the Unity3D engine, utilizing its 2D capabilities. Now I have been having a problem where eventhough an object is clearly grounded it somehow ...
1
vote
1answer
3k views

Rigidbody AddForce() skipping/teleporting

I'm surprised that this issue is nowhere to be found on these forums... Well at least when I searched. So, on my setup I have created a cube and applied a Rigidbody to the object with the following C# ...
1
vote
2answers
597 views

How to apply force to rigid bodys at a specific point?

I am trying to write a physics engine from scratch to get a better understanding of them. It worked pretty good so far, but there is one thing, i can't get my head around: If i have a rigid body ( ...
1
vote
1answer
36 views

How to set the force applied to RigidBody2D depending on the time user holds touch on screen?

I trying to make an object jump from 1 point to another point. How far it jumps depends on how long the player holds the touch anywhere on the screen. It jumps when player releases his touch. At the ...
1
vote
1answer
722 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 ...
1
vote
1answer
300 views

Copy velocity of one object to other object

I have a script to pick up items with a VR controller. I connect the object to the VR controller through a FixedJoint on a rigidbody ...
1
vote
1answer
2k views

How to give and remove authority of an object between multiple clients (Or how to let the client controller push a rigidbody)

I'm doing a cooperation FPS game in which players can push big rigidbody cubes with their rigidbody characters (the one from the standard assets). The problem is that the player hosting the game has ...
1
vote
3answers
7k views

Problems applying movement to a RigidBody in Unity

I'm working on a driving game, and I've been using RigidBody.MovePosition (non-kinematic) to move the car. I've read that this is not the best method for physics reasons, but I've had massive ...
1
vote
3answers
1k views

Rotate Rigidbody2d slowly for 360 degrees

I would like to perform a 360 degree rotation on a GameObject with rigidbody2d component. You should be able to see the rotation, so I thought of rotating the object 8 times with 45 degrees each ...
1
vote
1answer
6k views

Unity - How do I make non-convex Meshes collide with physics?

Whenever I add a Rigidbody component to an object with a non-Convex Mesh, Unity throws this error: Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported in Unity 5. If you ...
1
vote
1answer
1k views

Unity 2D Bullet AddForce does not work

I got the following code : ...
1
vote
1answer
238 views

Why does the box rotate, spin instead of gliding?

I've just learned that if I want to move an object so it acts depending of physics, I need to use rigidbody.velocity instead of ...
1
vote
2answers
59 views

Limiting interaction between certain RigidBodies

I'm developing a 2D game in Unity and have been tasked with building a particular feature I'm not sure how to accomplish with Unity's physics engine. To simplify, a bunch of objects of type X and O ...
1
vote
1answer
51 views

Platform Cannot move down when player collide buttom of platform Unity?

In my unity game I've arrange different platform ,when my player collide with upper part of the platform so platform falling down but issue that when my player collide to platform buttom of part so ...
1
vote
2answers
1k views

How to make rigid body move smoothly on uneven platform?

Right now I'm using Rigidbody2d for the game character along with polygon collider 2D(2d platform game). I'm beginner hope I'm using correct components. And transform to move character from left to ...
1
vote
1answer
3k views

Unity3D RigidBody adding force diagonally (x,y,0) results in two separate movements instead of one diagonal movement?

The intentions of this function are to utilize the RigidBody component from a "target" object and clear its force while applying a diagonal force in the direction upwards and away from the side they ...
1
vote
1answer
117 views

Trying to make a respawn trigger, but any rigid body (or collider probably) keeps triggering it. Any ideas?

I'm trying to make it so that if any object passes through with the matching tag it will reload the level. However, any rigid body (or collider) is setting it off which is not the desired behavior. <...
1
vote
1answer
72 views

Unity3d Rigidbody movement along slope slowdown

I have a Rigidbody character controller (Unity, C#) which I'm trying to make work seamlessly when walking on sloped ground. I've got it working fine walking up and down a slope by changing the forward ...
1
vote
2answers
465 views

Why does my first person camera attached to a rigid body vibrates?

I'm trying to make a first-person character with a rigid body. I need a rigid body because I want to add areas where the gravity comes from different directions so I also need to rotate the character ...
1
vote
1answer
93 views

body_entered signal won't emit when rigidbody collided to rigidbody

I have multiple rigidbody object floating away in the space. When they hit each other, they push away each. I want to destroy object if they hit something, but connect body_entered signal won't ...
1
vote
1answer
310 views

Rigidbody script throwing error CS0246: The type or namespace name `MouseLook' could not be found. Are you missing an assembly reference?

I've been stuck on this for the last 3 days and I really need some help. Now, I have 2 scripts that are giving me some grief, the RigidbodyFirstPersonController.cs and the MouseLook.cs scripts. On my ...

1
2 3 4 5