- Home /
Question by
Shadowman · Mar 02, 2014 at 09:41 AM ·
movementvector3gun movement
Can't Move Object? (Vector3.Lerp)
Hey Guys, This is my first time and I might miss something oblivious, but simply i am trying to move a game object (In this case a Gun) to a new position in front of the camera, but it won't do anything. I tried different ways using vectors but it wont budge. Here is the code.
`using UnityEngine; using System.Collections;
public class Zoom : MonoBehaviour { public bool Aim = false; public GameObject GunAuto;
void update()
{
if (Input.GetButtonDown("E"))
{
Aim = true;
}
if (Input.GetButtonUp("E"))
{
Aim = false;
}
if (Aim == true)
{
GunAuto.transform.position = Vector3.Lerp(GunAuto.transform.position, new Vector3(0.05678606f,-0.4925618f,0.4183655f), 1.0f);
}
if (Aim == false)
{
GunAuto.transform.position = Vector3.Lerp(GunAuto.transform.position, new Vector3(0.410768f,-0.5168345f,0.81342f), 1.0f);
}
}
}
Help and suggestions needed!
Comment
Best Answer
Answer by Lo0NuhtiK · Mar 02, 2014 at 09:58 AM
Update() needs to be capitalized, and also make sure in your project settings you have an input set up for "E" or change your if's to if(Input.GetKeyDown(KeyCode.E)) etc.
Thanks, Can't believe that i missed that capital U! Thanks Again!
Your answer
