# Tag Info

### Moving player inside of moving spaceship?

The ship stays in place and everything moves. Mostly. In this answer I present three ideas of how to go about it, and I'm referencing the games I'm basing them on. I could not find out what approach ...
• 27.2k
Accepted

### How can I "zero out" velocity in an arbitrary direction?

This is pretty simple linear algebra. You can make a little helper method for it: ...
• 135k

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

I created a little demo game a few days ago which demonstrates different ways to move a player-character. It might help you to better understand which way of moving is the right one for your ...
• 120k

### Why objects are falling equally in Unity

Check out the implementation of linearDamping in PhysX here (what Unity calls Linear Drag in the Rigidbody built on top of PhysX). It's equivalent to: ...
• 135k
Accepted

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

Here's a way to do this using Physics.SphereCast to test against the bodies' colliders without actually exerting any forces on them. It assumes that your cursor object is placed on exactly the same y ...
• 135k
Accepted

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

You're on the right track! This is something that usually the controller is responsible for. When you jump in a platformer you use a "isGrounded" variable to change how the controls behave while in ...
• 681
Accepted

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

When we parent a game object to another game object, we make the Transform values of the child object local to the Transform ...
• 5,273
Accepted

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

I've had great success by the following method. The idea is that, under the specific circumstance that the Rigidbody is in contact with a surface appropriately angled in relation to gravity(which is ...

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

Myself, I like to solve this by thinking of all player movement as acceleration-based. I choose a target velocity using whatever complicated control logic I like, then ask the player avatar to ...
• 135k

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

I wouldn't rely on the physics for this. If you have one dice, then you should just have some prebaked animations. You can have more than one animation per outcome to add variation. If you have ...
• 681
Accepted

### Can a GameObject be both 2D and 3D?

No, it can't. Unity won't allow you to add both a Rigidbody and a Rigidbody2D to the same game object: It also won't allow you to add both a 3d Collider and a 2d Collider: What you can have, though,...
• 120k

### implementing magnet like system in unity

I think what you're looking for is "damping." This is where you drain a little energy out of the system with each update step so that it settles into an equilibrium, rather than oscillating/vibrating ...
• 135k

### How to count rotations or spins when using addtorque?

Get the difference between the last and the current EulerAngles variable, add it to another variable, check that variable and if the variable is over 360, subtract ...
• 3,126
Accepted

### Unity : how to Rotate GameObject back to Indentity position?

I'd usually approach it like this: ...
• 135k
Accepted

### Objects do not stop when colliding each other while using mouse drag

The drag movement is not being applied through a force on the rigidBody but directly on the object's transform position, so what you are trying to do wont work. Instead you need to detect the ...

### Unity's CharacterController vs. Rigidbody with Collider

It's not either-or. It's both. Stick with the CharacterController initially. Go through the initial pain of writing it the way you want it under normal (kinematic) ...
• 30k
Accepted

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

OK, after a bit of tinkering, my brother and I finally found the answer. The issue is as follows: Enabling/disabling a BoxCollider (or any collider for that matter) doesn't wake up the RigidBody to ...
• 51
Accepted

### Proper way to set a RigidBody's maximum velocity

What you want to do is not to set the max velocity, but void applying any additional force once you get to a certain speed. Something like the example below. Watch the if statement ...
• 465
Accepted

### How to check if NPCs are on ground or not?

My advice for pedestrian-type NPCs would be: don't. For player characters, we often want to give them full freedom of motion to run and climb and leap or launch themselves around all over the place. ...
• 135k
Accepted

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

As Tom mentioned, after your second if call, you might have a third if statement such as: ...
• 146
Accepted

### Unity tilemap collider not colliding with rigidbody

I forgot to put a circle collider on the red circle. Leaving this up for others who might run into the same problem.

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

Revisiting this question, I just got a new idea: you could make a physics simulation in the background and cache the result, determine which face ended up, put the textures in the right place and play ...
• 286
Accepted

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

As you can see I able to get the Time.deltaTime which is I assume is how long the player hold the screen. Your assumption is wrong. Time.deltaTime gives you the ...
• 2,104

### Moving player inside of moving spaceship?

The main issues here are, roughly: Floating-point imprecision and catastrophic cancellation. An ordinary (single-precision) float has 23 bits of mantissa. Say you're moving at 1.0 m/s, and you add ...
• 161
Accepted

### Copy velocity of one object to other object

I will post this answer since this question was resolved by me in the comments above. In order to get the velocity of the VR controller, you need to use: ...
• 8,424

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

If your problem here is that when player is placing the ball, it pushes other balls back, then why not just turn isKinematic on and off? Turn off physics for all the other balls on the playing field, ...
• 3,126
Accepted

### Obtaining vector representing local z axis orientation

transform.forward already gives you exactly this. It looks like you might just be confused about how to visualize the vectors. You're repeatedly visualizing the ...
• 135k
Accepted

### How to count rotations or spins when using addtorque?

Might be advantageous to not demand a totally full circle (= airplane back completely horizontal rotation) for an "accepted roll" - maybe it's sufficient, and more user-friendly, to reach an almost ...
• 1,063
Accepted

### Problem when trying to use rb.MoveRotation in Unity

Caution: The trick shown here of using input in FixedUpdate worked at the time it was written in 2017 — Unity at the time had fresh input available from the very beginning of the frame, contrary to ...
• 135k