Tag Info

Hot answers tagged

2

It looks like your code to mirror the bullet's angle just flips the sign of the angle. This works great for reflecting an angle about the x-axis. 45 degrees becomes -45 degrees, etc. Now imagine reflecting off a wall that itself has an angle of 90 degrees. In this case, 85 degrees is reflected to 95 degrees; 45 degrees becomes 135 degrees, etc. Basically ...


2

you are in a voxel engine which means that each box should have a discrete x, y and z coordinate thus: if you have a box at index (x, y, z) then you can get all neighbouring boxes by getting the boxes at index (x, y +/- 1, z), (x +/- 1, y, z) and (x, y, z +/- 1) edit: after some more info... just detect the collisions for a line between the center of the ...


1

In this line here: Vertices[v] = Vector2.Transform(Vertices[v], rotate); You are overwriting your shape's vertices with the transformed vertices. The transformation you are creating is an absolute rotation, but you are applying it like a relative rotation. If this were simple algebra, you could use a relative rotation instead: Matrix rotate = ...


1

The path of fewest changes involves keeping your rotation sign as another variable in the function scope. You can acquire it by taking the cross product of the force and your moment arm. After your momentArm assignment, add the following: Vector3 rotation = Vector3.Cross( new Vector3(momentArm, 0), // the Vector3(Vector2 v, float z) constructor ...


1

Your question is not an exact duplicate, so I won't try to close it. But it's close enough that I feel comfortable in simply sending you over to my old answer on Supporting Multiple Resolutions. That answer is specifically for the XNA Platformer Sample, so you should probably download a copy of that to play around with to get a feel for how the code in my ...


1

What you probably want to do is create wrapper around SpriteBatch or create extension methods for SpriteBatch that apply the desired per-sprite inversion to each Draw call. Then you could just do: spriteBatch.DrawWorldSprite(texture, position, color); (You could even create an overload with a scaling parameter, that does appropriate multiplication so you ...


1

This should do the job, it will follow the player and face the player as well. Hope this helped. using UnityEngine; using System.Collections; public class ChasePlayerAI : MonoBehaviour { public Transform target;//set target from inspector instead of looking in Update public float speed = 3f; void Update() { //rotate to look at the player ...



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