Tag Info

Hot answers tagged

6

What you're doing sounds a lot like premature optimization to me. Did you try using the physics-engine and did it actually turn out to cause performance issues? If you don't need the physics-simulation and just care for the collisions, why not use sensors (or "triggers", as they are called in Unity). For stationary objects, use a collider with the Is ...


5

You should read up on Speculative Contacts for catching when collisions will happen before you end up with this kind of penetration.


5

This code is taking the collision between two spheres and moving them based on their masses and velocity. Here's a really basic illustration to show why there is penetration between a blue ball and a green wall. In this example the center of the ball is 5 feet from the edge of the wall. The ball is moving at 1 foot per second and you are running at a ...


5

I think your problem comes from multiple collisions. Consider three spheres A, B & C. A sits there. B hits A. Fine. C hits B. B is nudged into A. Oops.


4

I'm not sure but maybe you can connect both balls with an spring. if you don't want those two to change their distance you can put a very high value for spring constant. although this way the second ball also will effect on the first ball movement.


4

An impulse is an instantaneous change in velocity. You can calculate the velocity of a point before and after an impulse has been applied to the body. The velocity of a point is: V = Vcm + omega cross r V is the velocity of a point on a rigid body. Vcm is velocity at the center of mass. Omega would be angular velocity, and r is the vector from center of ...


4

I think the crucial part of this question is how you can procedurally generate stable structures (as generating an unstable pile of blocks in real time should be no problem) My approach would be to prebuild sub structures that are guaranteed to be stable. Have each substructure store two sets of spans" * one for the bottom where it requires contact below ...


4

Blender 3D is open source, and free. It is a modeling and rendering application, but it comes with easy to use soft-body, fluid, and ridged-body physics solvers. You could set up a number of slightly different simulations, that match the dimensions of the area in your game, and export the animation data from blender to use in your engine. In the game, ...


4

The documentation isn't terribly clear on it—and I'm not currently in a position to verify it—but I believe that the force applied from RigidBody.AddForce() (link) is applied at that object's root location (at its transform.position). If not at transform.position, then at the object's RigidBody.centerOfMass (link). If you want to apply a force ...


3

Thought I would post it as an Answer. When wanting to manipulate a RigidBody, You need to take into account the given Physics when Not-Kinematic. Many time in Games Dev there are 2 ways to Code Physics, Either follow the laws and implement them OR, fake the effect. A lot of things that go wrong in Unity is when Realistic Physics meets, Fake mimic. Both ...


3

Your solver needs multiple iterations (aka sequential impulse) over its contacts. Treat each contact point independently and calculate the impulse to resolve its contact constraint for that iteration. This may cause previously resolved contact points to be pushed back into the colliding object, but not by as much as the initial penetration. Perform ...


3

You seem to be answering your own question in your "question", and it seems to me like you are asking for clarification. Please note that my answer is Unity specific. Why use Rigidbodies? When you use a rigidbody, then you should use a rigidbody. Allow me to explain what I mean. Often times, when I see developers using rigidbodies; they are neglecting its ...


3

This article ("Advanced Character Physics" by Thomas Jakobsen, with a PDF mirror here that preserves images) discusses solving fixed distance constraints (which sound to me like your fixed joints) between particles by relaxation -- specifically you want the section "Solving several concurrent constraints by relaxation" on page 2, I think -- treating the ...


3

The usual tricks with weapons are: Make your character's collider large enough that it contains your weapons, then simply ignore collisions between it and the weapon's raycasts. Make it appear not to go through by drawing it on top of other objects. This works for FPS type games: Put the weapon(s) on a new layer (for this example it will be named ...


2

You could 'cheat' the system.. An 8 sided die only has 8 possible values. If you randomly pick a number you could then play 1 of 8 animations that end on the number that was randomly generated. You would not get it to look like a random roll every time, but it would roll to a randomly generated number. A second step to the canned animations would be ...


2

Add a character controller and use controller.move() with this you can make your character don't walk through the walls, if this wall have a collider.


2

To find a good algorithm for such a stance will take quite some time, observation and testing, I don't think you will find a "one-fits-all" solution on the internet. There is a lot you have to consider for skeletons climbing obstacles and I assume you don't only want it to take a certain stance, but to move from one to another in a realistic way. "Specific ...


2

Rather than building a solid object for your tentacles, I would suggest instead using a single linear chain — a 'skeleton' for the tentacle — and then procedurally wrapping a descending sequence of trapezoids around it, out to the tip. Use the local orientation information to define crossbars at each vertex (e.g., normal to the average or ...


2

Tentacles work in nature (and robotics) because of muscles inside, this means that each segment or three is only locally affected by a small number of forces. It sounds like you have a setup where all the force starts at the base and propagates outwards, which gets you a whip instead of a twisting tentacle. You may want to build a system with small forces ...


2

The direction of the force applied to a point colliding with your rotating object is the tangent to the sphere, perpendicular to the axis the sphere is rotating on. You should be able to calculate it with the following pseudo-code: vectorToContact = (pointOfContact - centerOfSphere); directionOfForce = normalize(cross(vectorToContact, axisOfRotation)) A ...


2

I think if you change the last line to this it should work. r.AddForce(Vector2(px, py).normalized * EXPLOSION_FORCE / Vector2.Distance(r.transform.position, transform.position)); normalize sets the vector to be length 1, then you multiply by some force and divide by the distance, so the further away it is, the less force is given.


1

Transform.position on a rigidbody won't do any collision checks and just costs more performance. Applying force to a rigidbody will move it while checking for collisions and such in a realistic sense. Things like moving up and down a ramp will be faster and slower (because of the direction of force) you could get around this by changing the direction the ...


1

I created a little testbed to test this. With standard mass and friction, a ball rolling will not stop. Applying either linear -or- angular dampening will cause the ball to eventually stop. If you don't want things like gravity to be affecting it, then angular dampening used by itself should work just fine. Likewise, replacing the sphere with a box in my ...


1

I'm guessing this is due to the collision resolution. Gravity pulls your character down and you start penetrating the slope. The collision is resolved along the slope normal, so you move out diagonally. Each frame the character moves down from gravity, and out slanted. You can imagine that since the resolution is slanted and gravity is downward, over time ...


1

You're checking the colliders like they're boolean variables. If a collider is inside colliders, it should have the explosion effect applied to it, there are no additional collision tests you need to do inside your foreach loop. However, you may want to check the type of object if you don't want things like power ups being affected by the blast effect. You ...


1

The easiest way to do this is to find yourself a physics engine. Since you're essentially asking how to create a physics engine. The equations and parameters you'd need are those of a collision detection and response system. If it's just for a simple animation, you can fake it using techniques like Rotoscoping and Onion Skinning to create the animation from ...


1

Rigidbodies awake when any force is applied to them. If you had a pool game and all the balls are sleeping and you would hit them with another ball, they would all wake up. I guess there is some minimal jittering going on that keeps your rigidbodies alive. There are a lot of parameters that can have an impact on this, but personally I would first and ...


1

No, setting the y-velocity isn't the correct way of doing things. You need to set the restitution of the object by passing the correct value (0 = no bounce) into the btRigidBodyConstructionInfo which is passed into the rigid body.


1

Of course it can be, but it won't be easy. Look at Spore by EA, they did it in 3D, and their level of freedom in designing your creatures there is amazing, and your creations there are complex simulated living organisms. What you want is something much simpler. What you will need is a validation system to follow a set of rules. You can't just go off ...


1

I tried to replicate your example and you're right: I had to set the plane's material to Ice to see the cube moving as it should. Without a material set to the plane, the cube won't "slide" forward (will do a simple somersault) for values like 25, and for bigger values (like 250) the cube's behaviour is really weird!!! (it moves forward, that moves ...



Only top voted, non community-wiki answers of a minimum length are eligible