I looked through the script reference page for contact points but I am still unsure on how to use it in my position. I have a for loop that applies to every object within the array setup with on trigger enter. The code is as follows:
function Update()
{
for(var hit in colliders)
{
//Set the Various Stats, calculated and read from varass, to each object
if(hit.rigidbody)
{
var waterLevel = transform.position.y;
var floatStats = hit.collider.gameObject.GetComponent("varass") as varass;
var floatForce = floatStats.bouyancy+((waterLevel-hit.transform.position.y)*5);
var returnSpeedX=(floatStats.IXPos-hit.rigidbody.rotation.x)*5;
var returnSpeedZ=(floatStats.IZPos-hit.rigidbody.rotation.z)*5;
hit.rigidbody.drag=1;
hit.rigidbody.angularDrag=1;
//Apply current and float force
hit.rigidbody.AddForce (floatStats.xCurrent, floatForce, floatStats.zCurrent);
transform.RotateAround (ContactPoint, Vector3.right, 2);
transform.RotateAround (ContactPoint, Vector3.fwd, 2);
}
}
}
In the place of 'ContactPoint' I want to call the contact point of each object on contact with the water. First of all do contact points work with a trigger or not, and if so what syntax would i use to find the contact point of each object in the array.
Thanks,
Langy
↧