- Home /
Question by
aidengaming123 · Apr 23, 2014 at 01:56 AM ·
rigidbodycolliderplaneonmouseover
How to use onmouseover with inputdown?
Hey guys, I've been experimenting with a script that shoots rigidbodies, but I want it only to shoot when a plane is clicked on. I have a collider set up, and copied and pasted a script. However, when ever I try experimenting with the "onmouseover" sort of deal, I always get an error. (I'm the biggest noob ever). Can somebody tell me how to use a script that pretty much says that if the mouse is over the collider, and buttondown("fire1") it plays the normal script? Here's the script: var projectile : Rigidbody; var speed = 20;
function Update () {
// Put this in your update function
if (Input.GetButtonDown("Fire1")) {
// Instantiate the projectile at the position and rotation of this transform
var clone : Rigidbody;
clone = Instantiate(projectile, transform.position, transform.rotation);
// Give the cloned object an initial velocity along the current
// object's Z axis
clone.velocity = transform.TransformDirection (Vector3.forward * speed);
}
}
thanks Also, I'm using the newest version of Unity.
Comment
This sounds like a good use case for Raycast. If you are bound on using On$$anonymous$$ouseOver, at least post what you did and what error(s) you got