- Home /
How can I change from spacebar to leftclick?
I have a script that I got from a shooting script with spacebar. I edited this script to just place the item, but i use first person controller. When I press space, I jump and place an Item. Can I change it to left click?
var bulletprefab:Transform;
function Update () { if(Input.GetButtonDown("Jump")) { var Bullet = Instantiate(bulletprefab, GameObject.Find("Spawn point").transform.position, Quaternion.identity); }
} @script RequireComponent(CharacterController)
Also Another question. Is there a way to get rid of the item with the spawn point touching it and with left click?
Answer by DryTear · Mar 14, 2013 at 01:59 AM
function Update(){
if(Input.GetButtonDown("Fire1"))
{
//Do your stuff...
}
}
just change from "Jump" to "Fire1"
Bah! He got it first... All you need to do it change the "Jump" to a different value. Now when you press "0" it will do the same thing. If you want your right click you can change it to (Input.GetButton ("Fire1")) and in your "input" menu change fire 1 to "rightmouse".
Answer by sparkzbarca · Mar 12, 2013 at 02:02 AM
function Update () { if(Input.GetMouseButtonDown(0)) { var Bullet = Instantiate(bulletprefab, GameObject.Find("Spawn point").transform.position, Quaternion.identity); }
Mark as answered and have a nice day. :)
Also, Can I add something to this script so that when the spawn point touches the item, i can get rid of only this item with right click?