Hello i have this script that works great but first when i collide with this object i want the script to run and keep going even if the player is mot colliding with it any more? how can i do this here is my code. also the 2 objects have colliders on them and they repel each other how can i get this to work?
#pragma strict
var target : Transform;
var smoothTime = 0.3;
private var thisTransform : Transform;
private var velocity : Vector3;
var offsetAmountx : float = 10.00;
var offsetAmounty : float = 10.00;
function Start()
{
thisTransform = transform;
}
function OnCollisionEnter(collision : Collision) { // Rotate the object so that the y-axis faces along the normal of the surface
var contact : ContactPoint = collision.contacts[0];
thisTransform.position.x = Mathf.SmoothDamp( thisTransform.position.x,
target.position.x +offsetAmountx,velocity.x, smoothTime);
thisTransform.position.y = Mathf.SmoothDamp( thisTransform.position.y,
target.position.y +offsetAmounty,velocity.y, smoothTime);
}