ConstantVelocity

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Removing all content from page)
m (Reverted edits by Joseph05408 (Talk); changed back to last version by Opless)
Line 1: Line 1:
 +
[[Category: MonoBehaviour]]
 +
[[Category: C Sharp]]
 +
[[Category: ReallySimpleScripts]]
  
 +
Author: Opless
 +
 +
== Description ==
 +
 +
 +
Useful for missiles, grenades, etc
 +
 +
== CSharp - ConstantVelocity.cs ==
 +
 +
<csharp>
 +
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;
 +
}
 +
}
 +
 +
</csharp>

Revision as of 19:20, 19 October 2009


Author: Opless

Description

Useful for missiles, grenades, etc

CSharp - ConstantVelocity.cs

<csharp> 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; } }

</csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox