Let's make things...
|
Gravity pulls downLet's go the other way.
VECTORS |
Direction + Magnitude
Easily confused with a position
Tremendously useful
Vector3 force = new Vector3(0,20,0);
rigidbody.AddForce(force);
|
RigidBody.AddForce(rigidbody.velocity * -1 * viscosity);
|
We need to know:
BoxCollider b = go.GetComponent
();
Vector3 size = b.size;
BoxCollider b = go.GetComponent
();
Vector3 size = b.size;
localDuckButt = new Vector3(2.3,0,0);
worldDuckButt = duck.Transform.TransformPoint(localDuckButt);
Debug.Log(worldDuckButt); // (-1,1,0)
|
Cross products!
Vector3 pointOutFront = position + (velocityDirection * 10);
for (float x = -width; x <= width; x += 1)
{
for (float y = -width; y <= width; y += 1)
{
Vector3 start = pointOutFront + (v1 * x) + (v2 * y);
if (Physics.Raycast(start, -velocityDirection, out hit, 10))
{
Push it!
}
}
}
|
Compare against every point! 50 times a second! Yay!
|
|
Break the water mesh into multiples
Vector3.magnitude has a square root
Vector3.sqrMagnitude is cheaper
raycast methods are not equal
Physics.Raycast(myRay, out hit, distance, layerMask); // 35% slower!
Physics.Raycast(start, direction, out hit, distance, layerMask)
Deep Profiler
ThreadPool makes some things super easy
ThreadPool.QueueUserWorkItem(myObject.MyMethod, threadNumber);
but it does have a tiny allocation!
No Unity api calls
l2w = transform.localToWorldMatrix;
// later, in a thread
worldPosition = l2w.MultiplyPoint(point);
Further Reading
Water interaction model for boats in video games- Jacques Kerner
(just google "Gamasutra buoyancy")