Tag Info

Hot answers tagged

4

You are right in your assumptions of what needs to be done! In physics engines, after a collision was detected but before the collision is resolved (The changing of the objects velocity) there are a few steps which need to be done. One of these steps is what I call decoupling: The process of separating two intersecting objects. This is the stage you are at. ...


2

I figured I'd come in and explain to you how I used to do my Rectangle collisions in XNA/Monogame. Firstly, I declare an enum that will serve as a way to indicate what axis we are going to be working with. This is important, as our calculations will be done one axis at a time. public enum Direction { Horizontal, Vertical } You will also need a ...


2

I would look at the problem differently: I would use navigation graph instead. I would "bend" the original navigation graph to your problem - each junction is a node(with 0 radius), and each edge stores its length and its direction. Player navigate on graph instead of in a world full of solid walls. Player can move each frame at desired speed along edge he ...


2

I've been implementing some very similar collide-and-slide collision detection and resolution. http://metareal.net/blog/wp-content/uploads/2015/08/2015-08-21.jpg The main key I found was to handle X and Y separately. So, your code might be modified something like this (a little freeform but you should get the idea): // step 1, modify X prevX = x; x += ...


2

That side force is the horizontal component of the road's normal with respect to the car's forward movement. Roads are banked like you are discussing to facilitate cornering at higher speeds without flying off the track from momentum pushing them to the outside corner. The banking pushes back in a direction the tires do not freely rotate and can hopefully ...


1

Assuming A at position 0,0 free fall equations (with starting velocity on x (Vx) , and g=gravity constant ) are: (1) x=Vx * t (2) y= (1/2)*g * t^2 substitute t in second eq. you get (3) y= (1/2) * g * (x/Vx)^2 where g and Vx are known. This is a parabola equation : Intersect (3) with each wall segment to get the eventualy collisions point ...


1

To determine the cone you should create some variables like AttackLength, FieldOfViewAngke and get enemy component to determine enemy position lookDirection = enemyPosition - player.transform.position; lookDirection.y = 0; attackDirection = Vector3.zero; float angle = Vector3.Angle(lookDirection, transform.forward); if (Physics.Raycast(enemyPosition, ...


1

i did something similar a while back, it's not that hard, one very easy and understandable way is : 1- rotate everything! means every line every object, so everything is simply flat! 2- calculate velocity, gravity, friction and ... anything you like ! just the way you always do in a flat and without rotation world 3- rotate everything back the way it was ! ...


1

I would do it like this: If the player wants to go around a corner/change direction, check if the distance he will be able to move in this tick (speed*delta, GREEN ARROW) is bigger than the distance from his center LEFT BLUE DOT to the connecting blocks center ORANGE RECTANGLE. If true: move him to the center of the connection-block ORANGE RECTANGLE and ...


1

Sounds like a simple rigidbody setting. Change from interpolate to extrapolate, or vice versa. http://docs.unity3d.com/ScriptReference/Rigidbody2D-interpolation.html


1

This will occur in Unity, if a GameObject is too small. The colliders will end up being either too far or overlapping, as the physics get unstable if the GameObjects are too small. Try making the gameobjects much larger (change the pixel per unit size), and you will see that it will more than likely fix your problem.


1

You could try changing the collision detection to Continuous or Continuous Dynamic. See the Unity Manual: Rigidbody for further info.


1

Use rigidbody.AddForce instead of transform.Translate so that the collisions are detected. For the direction create a variable with the difference between the target and the object itself and then normalize to find out the direction.


1

The answer is yes, of course. You test object b against all L1 nodes in the root because that's where it is. If a node is hit, add it's objects to the short phase (object to object tests) list. Then recursively repeat the process against those child nodes which were hit. Do this until you determined to hit or miss all leaf nodes.


1

The if (PlayerIsOnPlatform()) { this.Position -= new Vector2(0, 5); // Holds Player on platform. } is innocorrect. You need to calculate the depth penetration. IE: Calculate how far the player intercepted the other item. XNA has a method for this that returns the rectangle formed when two rectangles intersect. It returns the purple rectangle in ...



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