The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

2

If you think of the circle as a cone passing through the screen, with the point being in the center of the circle, you can reformulate it in a way that's pretty easy to code. The distance from the center will be between 0 and radius. But you want it to be 0 at the radius. So if you reverse it, you get something like this: for (float y = 0; y < 2.0 * r; y+...


2

Given that the arm exists in a 2D plane, the joints are hinge joints and not ball and socket joints, and the rotation arc for each joint is +/- maxangle: Let H = the position of the end effector. Let S = the position of the "shoulder" joint. Let Slen = the length from the shoulder to the elbow. Let Sdef = a normal vector representing the default ...


1

Read the error carefully - it took me a day to find out that the answer is in that error. See if somehow the scale of your game object becomes 0 or any of that side is overlapping with other side. If that happens, the box collider won't work and will give that error message.


1

TL;DR: you are updating the x position value while you want to update the y value. Please have a look at this part of your code: var poss = transform.position; poss.x = Mathf.Clamp(transform.position.x, -8.0f, 8.0f); transform.position = poss; What you're doing here is telling Unity: At every frame, (line 1) I want you to get ...


1

From what I understand the fact to compute your angle on Viewport space messes everything up due to origins. If you do your computation on Screen space everything will work just fine. Update your code with this: var p2 = Input.mousePosition + Vector3.forward * transform.position.z; var p1 = Camera.main.WorldToScreenPoint(transform....


1

Mathematically, it is not equivalent. I want to prefix this by saying; "but if it works for you, is more performant, and the player won't notice - then by all means still do it. Games are nothing but smoke and mirrors." The easiest way to check whether this will work or not, is to test a simple linear interpolation on a circle of radius 1. Here, we can ...


1

It looks like all you need to do is find how far your character's center is shifted left or right from your line's anchor point, then compute how much your line rises over that interval (or falls, if the product of x offset and slope is negative) float run = character.bottomCenter.x - line.position.x; float rise = line.slope * run; float collisionHeight = ...


1

The midpoint circle algorithm calculates a raster path by selecting pixels which are as close as possible to solutions of \$x^2 + y^2 = r^2\$. At each step, the path is extended by choosing the adjacent pixel which satisfies \$x^2 + y^2 \leq r^2\$, but maximizes \$x^2 + y^2\$. The algorithm takes advantage of the fact that a circle is symmetric. That is to ...


1

You can also do this with just vanilla collider setup and physics layers. Make two layers in your Tags and Layers settings: PlayerCollision — represents a solid player character PlayerTrigger — represents trigger-only interactions with player characters In your physics settings, tick the boxes so that the PlayerCollision layer does not collide with ...


1

Effectors! You could create two different kinds of gameObjects: One is a normal barrier, so you can just attach a collider2D and make sure that in the layers interaction matrix you allow interactions between the layer the player is in and the barriers' one; The other gameObject is similar but you additionally attach the PlatformEffector2D component to it (...


1

you have you have all events and callbacks for Both trigger and collider. for example OnTriggerEnter() and OnCollisionEnter() but if you want to use trigger event on a collider behavior, you can have duplicate collider component with one one them checked as trigger. you can make scale of trigger a little bigger for detection


1

To me its looks like "has exit time" is check. so set your transition from walk to dash like this: also apply same settings for transition Idle to Dash. "Has Exit Time": Exit Time is a special transition that doesn’t rely on a parameter. Instead, it relies on the normalized time of the state. Check to make the transition happen at the specific time ...


1

It turns out I was probably overthinking this quite a lot. The solution in the end was to just calculate the rotated position of the object by rotating their current position Vec2 by the inverse of the camera rotation. I could then sort by this rotated Y value.


1

BONUS ANSWER: The question is only asking for, "Can the arm reach the point?" However, the next question would typically be, "What angles do I set each joint to so that the arm is touching the point?" My first answer describes the set up nicely, so using the terms of the answer, I will answer the followup question. At this point, we know the absolute values ...


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