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
1answer
44 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
75 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
43 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
49 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
27 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
18 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
112 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
120 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
34 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
27 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
0answers
6 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
21 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
46 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
41 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
259 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
47 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
104 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
48 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
30 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
28 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
28 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 ...
0
votes
1answer
84 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
41 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
9 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 ...
0
votes
0answers
40 views

How do I expand my simplex in Expanding Polytope Algorithm (EPA) when the origin lies on it?

I'm doing GJK + EPA in 2D for collision detection + resolution. For GJK, I was using the vector (1,0) as my first support direction. However, if the origin happens to fall exactly on the simplex line (...
1
vote
0answers
32 views

how can I normalize the speed of a polygon moving over a series of connected quadratic bezier curves with varying lengths?

I am generating a bunch of quadratic curves that are connected together, creating an array of curves, and a function which returns the position on the curve for a given time. ...
0
votes
0answers
51 views

How to make Player consistently jump *to* a specific target rather than *towards* it?

I'm trying to make it so if my player hits "E" then they jump precisely to a specific target. The current code results in player jumping towards the target but not really making it there. I'...
0
votes
1answer
39 views

How to calculate the force for the fragments correctly?

I have a wall on which you can shoot cannonballs from a cannon, after hitting, I replace the wall with fragments of it. How to correctly apply force to the fragments of the wall after being hit? ...
1
vote
1answer
98 views

Should delta be applied to every change per frame ? (e.g. acceleration, deceleration, jump, etc.?)

I have written a game based on another game's original physics. I have all the constants the original game used in the Sega Megadrive. For example: ...
0
votes
1answer
88 views

How could I move an object, while respecting the gravity and other related physics in Unity?

How could I move an object, while respecting the gravity and other related physics in Unity? I tried using the following approach: ...
0
votes
1answer
73 views

Why is JumpHeight of 7f not visibly lifting Player off ground?

I'm using this code for Jump but when Space is hit, the character looks like they don't move. I played with JumpHeight and it turns out the jump does work; it just takes like 50f for it to finally ...
0
votes
0answers
13 views

Can't move up the CharacterController after applying gravity

I'm making a player with CharacterController and having trouble with handling gravity. Here's the code: ...
1
vote
1answer
46 views

Making Sprite Movement Appear More Natural

Currently I have a 2D game in which the player and a computer controlled (non-player) sprite move from point to point collecting tokens in a continuous environment. The player and the non-player ...
1
vote
1answer
24 views

A concise set of equation of physics that handles basic 2d physics for acceleration?

I am making an Asteroids clone and I want to implement proper physics for the objects. What equations would I use to calculate the acceleration? For example, I have a ship, and it might have ...
0
votes
1answer
22 views

How to detect all vertices within collision Area?

Using collision detection algorithms such as MPR (Minkowski Portal Refinement), GJK (Gilbert–Johnson–Keerthi distance algorithm), you can calculate the penetration depth in the collision. For 2 mesh ...
0
votes
1answer
69 views

Top-Down Tank Physics with Pygame

I am trying to make a top-down tank shooter game in Python and pygame, but I can't get the tank movement right. My objective is to make it move forward in the direction it is pointing in which would ...
0
votes
0answers
57 views

How can I make a wheel spin more freely using joints in Unity?

I am making a simulation physics based skateboard game in Unity3D. I want wheels that will roll freely based on the physics applied to them without any animation or drive forces. I achieved this ...
0
votes
1answer
51 views

How do I make a bomb sight accurately?

On the Bombsight Wikipedia page, I get that equation. I do not understand it very well. How would I go about writing that in C#? The drag doesn't matter in my project. It's not a flight sim. I know ...
0
votes
0answers
16 views

How to ensure that a randomly-generated velocity vector moves the camera forward within a valid arc?

I spawn a camera in a scene using random coordinates for x and y and setting z=0 and orient ...
0
votes
0answers
27 views

Unity 3D - Grappling Gun not making Player lift off the ground at all?

I have the following code (based on https://www.youtube.com/watch?v=Xgh4v1w5DxU but tried to convert to work with world space points for Third Person Character usage): ...
1
vote
1answer
107 views

Godot cutout animation with skeletons and ragdoll physics

i'm following the tutorial for cutout animation, but also wanted to combine ragdoll physics from this video, my goal is to make a 2d fight game with this 2 techniques. but not sure how to combine them ...
0
votes
0answers
60 views

How to decay sine or cosine wave so it takes one additional period to reach equilibrium

In many shmups, when enemies arrive, they accelerate onto screen, decelerate, and overshoot their static arrival position slightly, before backing up slowly to the position. This can be seen in many ...
1
vote
1answer
45 views

Box selection with Physics2D.BoxCastAll is mirrored when selecting in the bottom half of the screen

Using Physics2D.BoxCastAll based on rectangle is working fine when drawing is started on the top part of the screen, but when drawing is started on the bottom you can see this strange mirroring effect....
1
vote
1answer
51 views

Instantiated entities don't collide with each other

I've started to learn DOTS some day ago, and decided to create a simple project. When I added some simple physics to the game I faced the problem. I added one object on the scene and another ...
0
votes
0answers
19 views

How to make a variable height jump controlled by parameters?

I'm trying to make a variable height jump controlled by parameters. I want to be able to specify the max height of my jump, and a time to max height. I also want to be able to specify a min jump ...
4
votes
4answers
1k views

Physics-based marble race: how can you minimize the gap between first and last?

I'm building a 2D sideview marble game, where they race down the track via gravity. The problem is that once one gets ahead of the others, it usually wins. In racing games, they can address this by ...
0
votes
1answer
84 views

Calculating new Velocities of split Physics Body

Given a Physics body with all his properties i want to break the body into two or multiple parts that keep the original velocities. for linear velocity this should be original velocity + centrifugal ...

1
2 3 4 5
44