ConstantVelocity

From Unify Community Wiki
Revision as of 20:52, 10 January 2012 by NCarter (Talk | contribs)

Jump to: navigation, search


Author: Opless

Description

Useful for missiles, grenades, etc

CSharp - ConstantVelocity.cs

using UnityEngine;
using System.Collections;
 
public class ConstantVelocity : MonoBehaviour {
 
	public Vector3  direction      = Vector3.forward;
 
	// Use this for initialization
	void Start () 
	{
	}
 
	// Update is called once per frame
	void Update () 
	{
		rigidbody.velocity =  transform.rotation * direction;
	}
}

Javascript - ConstantVelocity.js

    var direction : Vector3 = Vector3.forward;
 
    function Update ()
    {
        rigidbody.velocity =  transform.rotation * direction;
    }
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox