Tag Info

New answers tagged

1

In general you can check if any Intersection exist between your two polygon (even non-convex) as below. Problem: Given n line segments; Report all(as k in algorithms) Intersections. You can implement any of these two algorithm in your desire language and use them. they take your line segments as input and return if any intersection ( Collision in your ...


0

I had similar issue, but my character stopped at some points. After adjusting rigidbody mass and physics material friction, it worked. Maybe it will work in your case.


0

Your problem statement is not consistent... You say you don't want rectangle corners to cross, so you have check collisions by corners. But when there's a slope, you want your guy to descend the slope, and let rectangle corners cross. The "desired position" rectangle shows this crossing. A solution is to keep checking the corners, and have your collision ...


0

This is my way for achieving this effect: void OnTriggerStay2D(Collider2D other) { Debug.Log("Object is in trigger"); player.rigidbody2D.AddForce (-Vector2.right*20000*Time.deltaTime); }


1

If in general clicking the unit has no other use than selecting the tile, you could simply put the units on the Ignore Raycast layer so you can select directly the tile, in this case you can also attach a script on the tiles with the OnMouseDown function. If you want to access, in that way, the unit, you could maintaing of structure describing the tiles (so ...


0

If you decided to research the MRP algorithm, I'd advice you to deal with GJK first. However I'm not sure, that the MRP is what you are looking for. The main idea of these two algorithms is very close, more over MRP does not provide information about contact point either. It should be mentioned that in contrast with GJK, MRP does not give the shortest ...


1

I updated the JSFiddle sample with the solution: Here's the updated version. It was just two lines of code: var sign = shapeA.id - shapeB.id > 0 ? 1 : -1; n.multScalar(sign);


-1

Found a solution, using the sign from the shapes order as a multiplication factor for the normal solved the problem. Just two lines of code: // Fix direction based on order of creation var sign = shapeA.id - shapeB.id > 0 ? 1 : -1; n.multScalar(sign);


1

To get the distance and the separation/collision normal you reduce the "circle to aabb" to a "point to plane" problem which can be easily solved. In detail: Get closest point from circle center to aabb Get distance from closest point to circle center Create a normalized version of this distance vector (Separation normal) Project the distance onto the ...


0

One of the possible solutions would be to disable unit collision in such tight spots. For example in the Starcraft game, workers (SCVs, Probes, Drones) don't collide with each other when mining crystals.


2

Get information (dimensions, coordinates) of two imageviews, then use rectangle intersection condition. Assume that two rectangles A, B with coordinate of top-left and buttom-right as follow: Rectangle A: (Xa1, Ya1) ; (Xa2, Ya2) Rectangle B: (Xb1, Yb1) ; (Xb2, Yb2) Overlap condition: ((Xb1 - Xa2)(Xb2 - Xa1) <= 0) && ((Yb1 - Ya2)(Yb2 - Ya2) ...


2

Refer the below site for some guidance: http://www.kilobolt.com/day-4-collision-detection-part-1.html It explains bounding shapes that will be used to check for collision. In the case of our robot, we will be using four bounding rectangles. I will suggest to give more specific requirement so that I can update my answer more helpfully.


0

How are you resolving these collisions? How does gravity or whatever work here? Your question doesn't really give us a whole lot to go one. It could be that the gravity is causing the player to sink into a tile, which is then resolved along the x axis, before the y. What I would do, is move on each axis separately. Move along the y axis , check, resolve. ...


1

Regarding your gravitation/acceleration physics, here's your code again with a bit of reformatting: function world.update(t) for k, v in pairs(world.objects) do if v.Static ~= true then v.Position.X = v.Position.X + v.Velocity.X if v.onGround == false then if v.Velocity.Y < world.Gravity then ...


2

The easiest way I found to do this was as follows: Make sure to configure your canvas to use screen space based on the camera. Drag and drop your camera into the render camera property Detect if the rectangle contains the mouse coordinates using RectTransformUtility.RectangleContainsScreenPoint() method. Pass in your rectTransform object, the current ...


0

I figured out how to detect pixel coordinates on a RectTransform by using the transform property to get the center of of the rect in pixel coordinates, then use sizeDelta to get the width and height, make a rect from that, then test it against the mouse coordinates. Vector2 topLeft = (Vector2)soundPanel.transform.position - (soundPanel.sizeDelta / 2f); Rect ...


0

I wouldn't use any permanent collision box that's moved around or anything similar. Instead, just play the attack animation and pick one specific frame where you're looking for collisions inside a specific area. Since I assume the overall attack animation will be rather short/fast, there shouldn't be any way to notice any difference. For example, the ...


2

No, but it will just be bad manners to write the same thing in every scripts and it can be a pain to debug if you have lots of function of collision detection in a lot of other scripts. You can use the method SendMessage() to communicate between scripts (or inside a script). You can read its documentation here e.g if(player.health == 0){ ...


0

I'm assuming that the physics engine for cocos2d-x already has this ability and you will just need to dig a little bit more. Otherwise, I'm also thinking of trying to implement something similar myself for a mockup game I'm trying to create. Right now (not sure whether it's a good idea or not) I'm thinking of adding a new property that determines what kind ...


1

The problem is with you using Rect box = this.guiText.GetScreenRect (); it returns size in pixels you need to convert it into unity3d units.


1

Everytime you call this fonction you set hasBlock to false. Console.WriteLine ("has block == true"); will be executed only if the player collides with two enemies on the same frame. The solution could be to use a static or a global variable.


1

The simple answer here is that as the developer, you are in charge of collision detection. But "who is responsible" is not really an important question when it comes to collision detection. The important question is: "How many pairs of objects must be tested for collision each frame?" Now, in a shmup most collisions take place between a bullet/munition ...


0

AABBs (Axis-Aligned Bounding Boxes) are (as the name suggests) without rotation. What you need are OBBs (Oriented Bounding Boxes), there are many tutorials on the web but collisions in 3D space are always either not good enough ore a pain in the back. Wikipedia provides a nice set of formulas ;) ...



Top 50 recent answers are included