Tag Info

New answers tagged

0

Solution: After a bit of digging with Google, I found this forum post asking what is/was responsible for strafe jumping being disabled in Siege Mode (Multiplayer). The last reply stated that the PM_Accelerate() was responsible for this. For my case however, it wasn't quite, however it did direct me to bg_pmove.cpp contained within the ...


2

First, it won't solve your problem, but there are a few general problems with your code. The conditions for your if branch will always be true if transform.localEulerAngles.x >= 0 and <= 360. The > 270 part is redundant since if x is less than 270, it is still possible to be >= 0. If x is 0 and lookAxisX is > 0, then adding -lookAxisX will make x < ...


1

You can always try to use the clamp method: Ref: http://docs.unity3d.com/ScriptReference/Mathf.Clamp.html Example transform.localEulerAngles = new Vector3(Mathf.Clamp(transform.localEulerAngles.x, 0f, 90f), 0, 0); **This is just a push in the right direction (above is untested)


2

jhocking's answer about dot product is the right answer to the question, but if you are rotating your object over time to face the right direction, inside that function you must be calculating how much you have left to rotate so that you know what direction to rotate and so that you don't rotate too far and overshoot. That means that inside that function, ...


3

Calculate the dot product to determine how close two vectors are. The dot product is 1 when they are exactly the same, -1 when they are exactly opposite, 0 when they are perpendicular, and decimal values when partway. So take the current direction, the target direction, then Vector3.Dot() and check if greater than .9 (or whatever threshold you decide looks ...


0

You can use Quaternion.LookAt() always and then just move your object forward whenever you want.


1

Since you are working in 3d world space, why not use the BoundingFrustum class? BoundingFrustum cameraBounds = new BoundingFrustum(view * projection); if(cameraBounds.contains(location)) { // it is in view } else { // not in view } edit. I assumed you are using XNA. If not, you can still reflect the XNA code to see how to make a Bounding frustum ...


3

If you would follow the second strategy, changes made to the Vector that got passed as parameter "v" will also be made to "vector2", since they are the same object. You should have a look at this question: http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value In Java every object is an reference, so you need to copy, for ...


0

If i understand correctly, you want to put a random target on the plane. However, your plane bounds.size are the "sides" of the plane, and do not start at the center. What you want to do is something like this: float scale = 0.1f; float moveAreaX = gameObject.GetComponent<Renderer>().bounds.size.x / 2; float moveAreaZ = ...


2

Solution for 2D vectors: Vector2 AB = B - A; // Vector from A to B Vector2 A0 = r * AB.normalized; // Vector from A to 0° Vector2 A90 = new Vector2(A0.y, -A0.x); // Vector from A to 90° Vector2 P = A + Sin(alpha) * A90 + Cos(alpha) * A0; // Coordinate of arbitrary point on a circle For arbitrary 3D vectors A and B in 3D space you need coordinates of ...


0

If you don't need a strictly physics based solution, bias and gain can be great for giving a nice organic (accel / decel) feel to a simple linear interpolation. http://blog.demofox.org/2012/09/24/bias-and-gain-are-your-friend/ http://demofox.org/biasgain.html


0

You could try setting a threshold from the target, and multiplying the object's speed by distance / threshold: acceleration = distance / threshold if (acceleration <= 1) { speed *= acceleration; } Here's an interactive example I threw together quickly: https://dl.dropboxusercontent.com/u/38185080/Flash/Examples/Deceleration.swf Checking gradual ...



Top 50 recent answers are included