Tag Info

New answers tagged

0

Try adding an if statement saying if neither of the axis are equal to zero then change the rotation, this would eliminate facing forwards when there is 0 on each axis. if(direction != Vector3.zero) {Quaternion rotation = Quaternion.LookRotation(direction, Vector3.up); transform.rotation = rotation; } Hope this helped.


1

I think you might be overcomplicating things - why not just set the "origin" of the hook to new Vector2(0, hookTexture.Height / 2) If you simply draw it like this: spriteBatch.Draw(hookTexture, position, null, Color.White, rotation, new Vector2(0, hookTexture.Height / 2), 1.0f, SpriteEffects.None, 0.0f); That way the hook is drawn and rotated around ...


4

Rotations are extremely order-dependent. Doubly so when you're composing rotations in local space (so the axes you're rotating around are themselves rotating from one frame to the next) As an extreme example, imagine that you start facing z+, and in one frame you pitch (x rotation) 90 degrees up. In the next frame, you yaw (y rotation) 90 degrees left. ...


0

Only change the rotation whenever your distance is above a certain delta. Also center your sprite, right now you're using the top-left corner of the sprite.


1

If you map the UV coordinates of a square texture to that quad it will automatically give you the effect you're looking for. In other words, map the texture the same as you would for the face of a cube; Upper-left: 0, 0 Upper-right: 1, 0 Lower-left: 0, 1 Lower-right: 1, 1 Unfortunately, doing it this way will cause perspective issues because you're ...


1

You might be able to side-step using rectangles altogether. For a top-down shooter you could use bounding circles instead of boxes. Checking collision between circles is much easier and faster than checking collision between non-axis-aligned bounding boxes (just check if the distance squared is less than the sum of the radii squared) and you don't need to ...


0

I have come up with a solution and it seemed to be buried deep within my college memory. I achieved what I wanted through a Unit Circle! Basic calculus/geometry seemed to be the correct way for me to come up with a working solution. I took the x and y translation points of the sun and put them through the unit circle equation. See ...


2

This is a script that keeps the rotation of the head to the rotation you set in the script, however it is very simple and may need adjustment to your purpose.(I have included sliders for easy editing). I hope this answers your question. using UnityEngine; using System.Collections; [ExecuteInEditMode] // This allows it to run during editmode(Makes it easier ...


1

I found the culprit. glm::degrees(angle) I had copy pasted that line from some guy off the internet who was for some reason converting the angle to degrees. There is absolutely no need for this conversion. According to a user on reddit: One warning about this method, your model matrix will degrade over time using this kind of technique (repeatedly ...


0

I assume your rectangle exist out of a X,Y,Width and Height. First, Create 4 Vector2 for your rectangle: Vector2 v1 = new Vector2(x,y); Vector2 v2 = new Vector2(x+width,y); Vector2 v3 = new Vector2(x,y+height); Vector2 v4 = new Vector2(x+width,y+height); These points are the 4 corners of your rectangle. Next apply some simple transformation on the ...



Top 50 recent answers are included