Tag Info

New answers tagged

2

You can attach the sprite to the child of the main game object which handles the collision detection logic. Whenever you want to flip the sprite just do it on the child object leaving the main object as it is. This way you can achieve your desired result :)


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 ...


0

Read Real-time Collision Detection. By far the best on the subject imho. Implement Spacial Partitioning of the objects in your scene. (kd-tree or octree or etc...) This is by far one of your most important components (when it comes to simulation [like col. det.] or rendering) Implement a Bounding Volume Hierarchy (BVH) for your objects - grouping the ...


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 ...


0

This is the approach I usually go with. C# Example class Scene { public int Width; public int Height; public List<GameObject> Objects; /* TODO: Initialize the collection. */ public void AddObject(GameObject gameObject) { this.Objects.Add(gameObject); gameObject.Scene = this; } public void ...


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 += ...


0

Use the SKPhysicsBody instances as keys to a dictionary of game objects. When you want to process a collision, retrieve the game object associated with the physics body from the dictionary. Not as efficient as the direct link you sought, but more than sufficient for most purposes.


0

Look at the classes in Rect, specifically .intersects(Rect a, Rect b) is boolean and saves having to do all the math yourself.


0

I forgot to come back to this question when I arrived at an answer, but this has gotten a decent amount of views over time, so better late (even 2 years late) than never! First, prerequisites: Prerequisites: First, one has to be able to calculate the time of collision (TOC) of two circles. Step 3 of this question Small, High-Speed Object Collisions: ...


0

For getting all the colliders which are below the touch position , we need to use the RaycastAll function. This returns an array of hits from which we can determine the GameObject which is at the farthest distance from the camera. Also take care of the situation where no objects where detected, to avoid the null reference error. void Update() { ...


0

To detect the direction that your player is facing you can use transform.forward as a vector3 value .


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, ...


0

I believe this happens because the bullet's speed is very fast so the collision doesn't have enough time to be detected, that's why I prefer using raycast for the shooting.


0

There should be an object that holds your texture and to that object you could add a collider.


0

I though you could try to check if the player is touching or near the "Not walkable" layer the destination changes to himself so he stops.


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 ! ...


0

Could you post your update loop? I don't immediately see something wrong with the code you posted which causes this behavior so it is possible the problem is somewhere else in your code. Usually you would do something like this when programming a simple physics engine in your game: 1. Update positions of the objects based on their velocity 2. Check for ...


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 ...


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 ...


0

To prevent the check of the object colliding against itself, just check the reference like so: Core.objectCollision = function() { if (Core.Mouse.isHolding != null) { for (i in Core.Objects) { // Skip the object that was grabbed. if (i == Core.Mouse.isHolding) continue; if ...


0

You only have to find the intersection point in your LineIntersectsLine method. Add something like this last: Vector2 t0 = l1p2 - l1p1; Vector2 t1 = l2p2 - l2p1; Vector2 t2 = l2p1 - l1p1; float dotDPerp = t0.X * t1.Y - t0.Y * d.X; float t = (t2.X * t1.Y - t2.Y * t1.X) / dotDPerp; Vector2 intersection = l1p1 + t * t0;


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.


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. ...


0

It's a fairly simple fix...just had to add animation speed & it worked.


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.


0

I think a normalized vector from the ball to the object. direction = (ball.transform.position - kicker.transform.position).normalized; I made a game doing kind of this thing you are doing. (source code link in the post) http://luigigarcia.byethost7.com/projects/goal-a-r-goal/ I think that your kicking object must do this work, not the ball. You need to ...


0

R-trees and AABB-trees are two names for the same thing, so it doesn't make any sense to say one has an advantage over another.


0

I'm unfamiliar with Farseer, however in my own physics engine I handle this by getting an array of collisions which occurred in a given time-step and using the result of the Dot Product of the collision normal with the positive Y axis to see if any collision surface is within a certain angle of being parallel to the floor. Raycasting is probably a better ...


0

Overlap: +Low cpu cost +Easy to implement -Doesn't work if objects have a too high velocity, are too small, or if the default fps is too low. Basically, bullet physics aren't supported at high velocity In most cases, this is what you should go for. Intersection: +Allows bullet physics, even at crazy velocities +Looks prettier in general, because of the ...


0

If there's gravity applied to your object you could check if the Y velocity==0 after you've done your collisions. It's maybe a bit fake it if you can't make it but in most situations it should work


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 ...


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 ...



Top 50 recent answers are included