- Home /
Question by
trinitysj96 · Feb 14, 2013 at 08:29 PM ·
velocityshootingtranslatetransform.translate
Error: Method not found: 'UnityEngine.Rigidbody.Translate'.
function Fire() {
startpoint.transform.LookAt(transform.position);
// create a new projectile, use the same position and rotation as the Launcher.
var instantiatedProjectile : Rigidbody = Instantiate (projectile, startpoint.position, startpoint.rotation);
// Give it an initial forward velocity. The direction is along the z-axis of the missile launcher's transform.
instantiatedProjectile.velocity = startpoint.TransformDirection(Vector3(0, 0, initialSpeed));
//instantiatedProjectile.TransformDirection(EnemyHitPoint.position);
instantiatedProjectile.Translate((EnemyHitPoint.position - instantiatedProjectile.position) * Time.deltaTime);
//instantiatedProjectile.TransformDirection(EnemyHitPoint.position);
// Ignore collisions between the missile and the character controller
Physics.IgnoreCollision(instantiatedProjectile.collider, startpoint.root.collider);
}
I get an error with the code above. however the function still works as expected in the game play... not sure what is wrong with it or why the error?
Any ideas?
Comment
Best Answer
Answer by Benproductions1 · Feb 14, 2013 at 10:02 PM
Translate is not part of a Rigidbody, but it is part of a Transform.
All you have to do is change it from instantiatedProjectile.Translate
to instantiatedProjectile.transform.Translate(...
It still works as expected, because your translate is only called once per projectile. If it has a rigidbody, it will move by itself, no need to move it yourself.
Hope this helps, Benproductions1
so i did take that line out completely and it still works, no errors and it works better that it was before.. thanks for the info.