Questions tagged [physics]

Relating to the motion of objects through space and time. Including concepts such as acceleration (thrust and gravity), mass, collision response, friction and more.

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

Implementing Linear Diagonal Movement Relative to Camera Rotation

So far I've implemented horizontal (X-axis) and vertical (Z-axis) linear movement for the player in a 3D game. Using the code shown below, the player is able to move relative to the camera's Y-axis ...
0
votes
1answer
27 views

How do you make Cube not instantly rotate upon Keypress in opposite direction?

I have this movement script on a Rigidbody cube with X,Y,Z Rotation Constraints. It is working well to move and to rotate in the direction of the movement. However, ...
0
votes
0answers
29 views

What causes Rigidbody character to suddenly move at fast speeds?

I'm trying to make a Rigidbody-based movement script for a character. It behaves pretty much as expected, but every once in a while the character will suddenly run at a massive speed. I can't find a ...
1
vote
1answer
44 views

How do I get the consistent time it would take for two points to reach each other in circular motion?

I'm making a 2D game. It involves the player swinging around a grapple hook in perfect circular motion, however, I want to make the cooldown for this ability based on predicted end position for the ...
0
votes
1answer
20 views

How to make trigger function respond to certain collider pairs and not others?

I assigned two colliders to one GameObject. Both are different sizes. I am doing operations with Trigger messages. I want this Trigger function to work for only colliders 1 and 3, but not collider 2.
0
votes
0answers
50 views

Unity - Billiard balls unrealistic movement

So, I have this problem, even when I apply a small amount of force, the balls seem to get pushed away easily. Here's how they should behave (GIF from 8 ball pool game): And here's how I have it : ...
0
votes
1answer
31 views

Ball's spin speed seems to change erratically after AddForceAtPosition impulse

I'm trying to make a billiard game, and trying to add "spin" (aka English) functionality. The way I'm using to add spin is by using AddForceAtPosition(). Here's the code: ...
0
votes
0answers
42 views

How to implement crowd movement in Unity without rigidbodies?

I am working on a mobile game where its core gameplay includes a bunch of objects (can exceed 100) walking around autonomously in an environment where they push each other and get pushed by other ...
0
votes
0answers
26 views

High rigidbody drag value gives weird speed readings

when calculating speed in unity ...
1
vote
1answer
15 views

How to snap a point to the height of the navmesh surface?

I'm making generator for EQS and need to put points on navmeshes located on different heights, one above other. So, my idea is to make raycast vertically and find intersection points with navmeshes. ...
0
votes
1answer
44 views

How to calculate accelation times and vector to orient a pointmass to a new orientation

I'm trying to design a space game where the user has 2 types of input: forward and backwards thrust in the current direction change orientation The game is based on actual physics, for the sake of ...
1
vote
0answers
30 views

Maths behind Unity rigidbody.AddForce

I've tried to understand the Maths behind AddForce, as to reproduce it using rigidbody.velocity +=. Based on the formulas ...
1
vote
0answers
39 views

Character movement on irregular surface in Unity

I'm currently implementing a system in Unity where I generate an approximation of a blood cell and treat it as a planetoid, as if you're playing Super Mario Galaxy, and you're running around the ...
0
votes
0answers
10 views

PhysX Dealing with CCT and static rigid body collisions

recently I've been implementing physx's CCT system to my engine. The problem is that there is absolutely no collisions between CCT Actors and static rigid bodies. As I write these words I still can't ...
0
votes
0answers
48 views

character movment and physics on 2d game

I'm developing a client/server multiplayer game. in server side i need prevent players cross map objects like walls also i need prevent player go inside each others, instead want to slide them along ...
0
votes
1answer
30 views

How do collisions work under the hood in Unity? Is it more performant to make (physics) Layers as specific as possible?

I'm trying to decide how granular to be with my layers. I assume there's some spatial indexing going on, but... Does Unity do work for every pair of objects on compatible layers? Will Unity do some ...
11
votes
1answer
3k views

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

I'm currently running into an issue with my character controller using physics-based movement of rigidbodies in Unity. Here's an illustration of the issue I'm facing: Basically, after a jump, my ...
0
votes
1answer
38 views

How to knock animated character backward when sword strikes wall

I was wondering how to make animation and physics interact. Specifically, I want to make it so when my character (rigidbody) plays a sword hit animation (swinging the sword in front of it), it makes ...
1
vote
2answers
55 views

Applying friction separately to forward and side directions

I'm making a movement-based, first-person 3D game where the player should be able to gain a lot of horizontal speed over time with WASD, but also will stop due to friction very quickly the moment they ...
0
votes
1answer
47 views

confusion on desired velocity

In one of the videos of the dead earth game dev series , the author mentions of calculating a local desired velocity of a NavMeshAgent. My point of confusion was, ...
0
votes
1answer
87 views

Deceleration via Lerping

I have written some code that creates a very nice uniform angular acceleration for an object moving around a circle. It effectively uses linear interpolation but ramps the interpolant such that the ...
0
votes
0answers
23 views

Dynamic circular motion increases in energy

I am experimenting with designs for physics engines for which I use particles and fields like magnet fields. In magnet fields you have a thing called Lorentz force ...
1
vote
1answer
49 views

Physics and unit size to feet

I'm dropping a object 1353 feet from a building. I can get the time(t) it lands with manipulating the total displacement of a object(/\x). Gravity is 32 feet/s^2 While doing physics, kinematics or ...
0
votes
1answer
80 views

How do I make an object bounce off the wall?

I am spawning objects at a random place at the top of the screen, tilted at a random angle like this: ...
2
votes
1answer
83 views

How to make mouse pointer be the vertex of a drawn parabola when estimating the trajectory of a projectile?

I'm trying to remake an old flash game using Unity. The main mechanic of the game is to make the basketball pass over the mouse. Here's a video of the game: https://www.youtube.com/watch?v=6sArMC1l_Sc ...
0
votes
1answer
86 views

Making vehicle using WheelColliders faster

I have a driving game and use wheel colliders to control cars, but whatever I change with the WheelCollider components it doesn't get faster and is way too slow. The code of the controller: ...
1
vote
2answers
65 views

How can I keep a mesh connected and upright?

I'm pretty new to both programming and Unity, and I honestly have no idea how to accomplish what I want to do. Scene: I have a Sphere which I can control with my keyboard. It rolls around on a plane ...
0
votes
0answers
31 views

How to predict future position of body in solar system?

I have a solar system where each body interacts with each other by force F = Gm1m2/R^2 Is it possible to predict future position of some random body after t seconds since bodies velocity and position ...
1
vote
1answer
20 views

Odd behaviour when changing rigid body velocity inside OnCollisionEnter2D

This is the code I'm using to make an object bounce across the scene: ...
2
votes
2answers
215 views

How to use different drag values for the X and Y axes on a Rigidbody2D?

I'm building a small 2D character controller using Unity physics to simulate an oldschool platformer. I know this is not the best way to do it and I have my own version using just raycast and custom ...
3
votes
2answers
181 views

Why do multiplayer games often use custom physics implementations?

Big game engines all have a physics engine whose job is to resolve forces, collisions and constraints efficiently. I think the majority of modern games use a physics engine to some extent. ...
0
votes
1answer
48 views

Reach a moving point smoothly

First, for my specific problem, we can assume we're working in a 1D space. I have a point B moving at a specific velocity V. I want to smoothly move the body A so it reaches the point B and moves at ...
0
votes
0answers
32 views

Predicting angle of projectile trajectory

I'm making a game, where the player and AI shoot projectiles. Projectiles have their own speed, drag and gravity modifiers. I update my projectile velocity in FixedUpdate (I use Unity engine). ...
0
votes
1answer
15 views

Can a BoxCollider 2D be a child object of a Rigidbody 2D ? (as it's not working)

I tried to find a solution before and asked elsewhere but couldn't find the exact same issue. I have a parent game object that is a Rigidbody 2D, and this object has children that are BoxColliders 2D. ...
0
votes
0answers
27 views

Unity: how to make a kinematic rigidbody react to a rigidbody hitting it?

How do I make a non-kinematic rigidbody react to a "normal" rigidbody colliding with it in Unity? Like when the rigidbody hits the non-kinematic one, it pushes it back (note: not using the ...
0
votes
0answers
14 views

How do get fast leaf nodes collide with a leaf node in bvh tree. ( I don't wanna traverse top-down )

How do get leaf nodes collide with a leaf node in bvh tree. I wanna leaf node list collide with a leaf node in bvh tree. I'm doing this traversing bvh tree from top node. But It really slow because ...
0
votes
1answer
60 views

Problems with collision order of resolution

I have two objects, A and B, and I need help to solve the following problem about the collision resolution order: A and B are moving with the same speed, and they don't move both at the same time A ...
0
votes
0answers
12 views

How to find the center of mass from CapsuleCast in unity

Is there an easy way to find the center of mass from a CapsuleCast, or should I find the geometric center of it?
1
vote
0answers
42 views

Object stuck against an obstacle still pushes other objects away

I have an object pinned against the ground by a revolute joint. A motor on the joint makes the object spin. Sometimes the object becomes stuck pushing against a static body. When it happens the object ...
1
vote
1answer
262 views

Firearm magazine ejection

I am playing around with a VR game where the player can fire a hand gun. When the magazine is empty they can press a button on the controller to eject the magazine from the gun. As its VR, I would ...
0
votes
0answers
61 views

Prevent velocity from being increased by fixed joints

I am currently working on a Unity project that makes use of fixed joints. When connecting two GameObjects using a fixed joint, I noticed a behavior where the gameobject that becomes part of a fixed ...
1
vote
2answers
108 views

Simulating a rocket out of control in Box2D

In the void of space, a spaceship releases a rectangle shaped space-torpedo. In half a second, it starts its rocket engine and goes straight until something get in its way, and then boom! The code ...
2
votes
1answer
60 views

Detecting Surrounding GameObjects

Some Background Context: So I have a 2D prototype in Unity I am working on that has enemy entities that have rigidbody2D component set as dynamic as I am using physics (...
0
votes
1answer
39 views

Why addForce creating some small movement in my game object?

I'm working in a project with Unity 2d where player walks on a small planet. I try to use some code from youtube tutorial to apply gravity to my planet.This code consists of two parts, Attractable and ...
1
vote
0answers
31 views

How can I make this motion collide against a wall

EDIT I've actually commented out the motion in my code and adapted it to try reproduce this post.After a chat with @DMGregory he told me to use velocity reflection but as you can see in the following ...
1
vote
1answer
32 views

Space torque semi-independent of center of mass

I am making a 2d user build spaceship game that allows the user to place thrusters where they would like. I've read a bunch of posts in a lot of places including stack exchange on how determine the ...
1
vote
1answer
88 views

How can I create this springy oscillating motion chasing / orbiting the mouse?

I'm trying to recreate this motion, I think most of the motion is based on this formula \begin{eqnarray} x(t) &=& A e^{-\gamma t/2} \cos(\omega t - \phi) \\ y(t) &=& B e^{-\gamma t/2} ...
0
votes
1answer
50 views

Networked game with physics and client side prediction and server reconsiliation causes lag

I'm trying to make a multiplayer platformer game. I can almost get client side prediction and server reconsiliation to work, but there is one issue that I just can't wrap my head around. Lets say that ...
0
votes
0answers
19 views

Rigibody2D remove push-power

I have a player's prefab. The game is online, so when the player joins I place this prefab on the map. There are other players on the map. The player himself is controlled by Rigibody2D component ...
0
votes
0answers
26 views

How do you make a Unity 2D ball roll down a LineRenderer EdgeCollider2D incline?

How do you roll a 2D Image sprit ball using just the Unity builtin physics components on linerenderers with EdgeCollider2Ds? Tested my setup to work with physics. And PhysicMaterial2D so it bounces ...

1
2 3 4 5
44