scripting error (tornado twins tutorial)

hi everybody i trying to do this tutorial from tornado twins but i got thiis error

Assets/script/torrentcontrol.js(8,51): BCE0020: An instance of type ‘UnityEngine.Transform’ is required to access non static member ‘rotation’.

here is my script

var LookAtTarget:Transform;
var damp = 0.6;
function Update ()
{
if(LookAtTarget)
{
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
transform.rotation= Quaternion.Slerp(Transform.rotation,rotate,Time.deltaTime * damp);
}
transform.LookAt(LookAtTarget);
}

3 Answers

3

Here is your script formatted correctly

var LookAtTarget : Transform;
var damp = 0.6;
function Update ()
{
    if(LookAtTarget)
    {
          var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
          transform.rotation= Quaternion.Slerp(Transform.rotation, rotate, Time.deltaTime * damp);
     }
      transform.LookAt(LookAtTarget);
}

Now then your problem is a simple one. On this line:

transform.rotation= Quaternion.Slerp(Transform.rotation, rotate, Time.deltaTime * damp);

The first parameter “Transform.rotation” should be “transform.rotation” – no capitals

Crap, you beat me to it :D

You capitalized the ‘T’ in transform.

This should work for you:

var LookAtTarget:Transform;
var damp = 0.6;

function Update () 
{ 
	if(LookAtTarget) 
	{
		var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position); 
	 	transform.rotation= Quaternion.Slerp(transform.rotation,rotate,Time.deltaTime * damp); 
	} 

	transform.LookAt(LookAtTarget);
}

If an answer helped you, remember to check it as correct. It improves the search function, marks the question as finished, gives people a better impression about you (I've seen people refuse to answer a question solely because the asker doesn't check correct answers), and it gives a nice karma cookie to people who helped you.

now i have other error
var LookAtTarget : Transform;

var damp = 0.6;

var bullitPrefab : Transform;

function Update ()

{

if(LookAtTarget)

{

      var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);

      transform.rotation= Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);

 

  transform.LookAt(LookAtTarget);

  

  Shoot();

  }

}

funtion Shoot()

{

  var bullit = Instantiate(bullitPrefab,transform.Find("spawnPoint2").trasnform.position,

                                        Quaternion.identity );

    

  bulli.rigidbody.AddForce(transform.Forward * 10);

}

Assets/script/canoncontrol.js(18,8): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/script/canoncontrol.js(18,16): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/script/canoncontrol.js(22,7): BCE0043: Unexpected token: var.
Assets/script/canoncontrol.js(22,10): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/script/canoncontrol.js(26,1): BCE0044: expecting EOF, found ‘}’.