i have a 2D platform game with a plane it has animation clip to, a up and down wards tilt
This is the script im using to make it fly along the X Y
function Update () {
var x = Input.GetAxis(“Horizontal”) * Time.deltaTime * PlayerSpeed;
var y = Input.GetAxis(“Vertical”) * Time.deltaTime * PlayerSpeed;
transform.Translate(x, y, 0);
and with my animation script i have this
function Update () {
if (Input.GetAxis(“Vertical”) > 0.2)
animation.CrossFade (“Up”);
else
animation.CrossFade (“Idle”);
}
I have no clue what im doing, im pretty sure my animation script is not right, ive been toying with it for 3 days and i cant get any where. so if some can help me that would be great.i can only get the up key to work but,my plane then locks it self on position 0,0,0 and i cant move any more the plane will tilt up but thats it no movement? can some one please help me.im a new starter with this java script but im trying to learn and its fustrating me
ive also tryed
function Update()
{
if (Input.GetKey(“w”))
animation.Play(“Up”);
else
if (Input.GetKey(“s”))
animation.Play(“Down”);
}
the plane tilts up and down but still no movement, and after that code i dont know how to add the crossfrade.
I think you need to combine the two scripts so that when the animation is played it also moves the plane
function Update () {
//Try to put all things needed in one code block. :smile:
if (Input.GetAxis("Vertical") > 0.2) {
animation.CrossFade ("Up");
var y = Input.GetAxis("Vertical") * Time.deltaTime * PlayerSpeed;
transform.Translate(x, y, 0);
else {
animation.CrossFade ("Idle");
}
if (Input.GetAxis("Horizontal") > 0.2)
animation.CrossFade ("Up");
var x = Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed;
transform.Translate(x, y, 0);
else {
animation.CrossFade ("Idle");
}
}
I have’nt tested this yet but will later 
and will edit it unless one of the pro’s want to correct me.lol Cause I claim to be no code jedi.