Using angularVelocity to line Rigidbody with target

Hello all,

I’m trying to get a rigid body to alter it’s angularVelocity so that it will face itself towards target in a turning function.

empty.transform.LookAt(player);
rigidbody.angularVelocity = //Don't know what to put here.

angularVelocity must be used, attempts with using transform.rotation with Quaternion.Lerp results in the rigidbody fighting with the floor and walls.

Thanks in advance.

From the docs…

Quaternion.Lerp is probably what you want. Might be something else causing the fighting. Tough to say without seeing what else you’re doing.

Quatronion.Lerp is defiantly not what I want. I am writing a HalfLife2 style carry object script. I do not use constraints as they could never fully give me the desired effect (Undesirble bounce off spring and items penetrating walls with fixed, both not demonstrated in the HL2 mechanic). I directly alter the velocity of the rigid body being picked up, and scale it down when touching surfaces so that the object doesn’t penetrate floors and walls, this has given me the desired effect.

However what I am trying to do now is get the object to face the player when it’s being carried, in order to avoid carried items from penetrating floors or walls I need to do this via the angularVelocity variable and not by any of the functions that take a quatronion. I would need to somehow convert a quatronion into angularVelocity.

Here’s what I have so far

private var item:GameObject;
private var triggerFired = false;
private var fire = false;
private var mass : float; // Original mass of object

function Update () {

	if(Input.GetButton("Fire1"))
	{
		if(!triggerFired)
		{
			triggerFired=true;
			fire=true;
		}
	}

	if(Input.GetButtonUp ("Fire1"))
	{
		triggerFired=false;
		fire=false;
		if(item){
			item.rigidbody.useGravity = true;
			item.rigidbody.mass = mass;
			item=null;
		}
	}
	
	if(fire){
		fire = false;
		var hit : RaycastHit;
  		
		if (!Physics.Raycast(Camera.main.ViewportPointToRay(Vector3(0.5, 0.5, 0.0)), hit, 10))
  			return;
  	
  		if (!hit.rigidbody)
  			return;
  			
  		item = hit.rigidbody.gameObject;
		item.rigidbody.useGravity = false;
		mass = item.rigidbody.mass ;
		item.rigidbody.mass = 0.1;
	
		//print(item.name);
	}

	if(item)
  	{  
		var mark = item.GetComponent("Marker");
  		vel =(((transform.forward * 5) +transform.position) - item.rigidbody.transform.position)*((mark.isTouching)?(5):(10));
  
  		item.rigidbody.velocity = vel;
		mark.looker.transform.LookAt(transform);
		
		var rot = Quaternion.LookRotation(transform.position - item.rigidbody.transform.position, Vector3.up);///Quaternion.Lerp(item.transform.rotation, mark.looker.transform.rotation,Time.deltaTime*10);
		rot = Quaternion.Slerp(item.rigidbody.transform.rotation, rot, Time.deltaTime*60);
			//item.rigidbody.angularVelocity = Vector3.one;
		item.rigidbody.angularVelocity =  rot * Vector3.forward;// item.rigidbody.angularVelocity * rot ;// (Quaternion.Lerp(item.transform.rotation, mark.looker.transform.rotation,Time.deltaTime*10));
  	}

}

Goes into carryable items:-

var isTouching = false;
var looker:GameObject;

function Update () {
}

function OnCollisionStay(collision : Collision){
	isTouching = true;
}

function OnCollisionExit(collision : Collision){
	isTouching = false;
}

[/code]