Hi Guys,
This one has been driving me crazy. I’ve actually considered giving upon my game cause i cannot for the life of me figure out this simple concept (to most of you)
I have a Idle Animation - just 1 frame
I have a Walking Animation
I have an animation Controller
I haven’t setup any transitions in the animation controller because im confused - Except Default to Idle with no conditions. i have also placed the walking animation in there as well with no transition conditions.
I have named the animation “TrumpWalk” i have tagged the animation “TrumpWalk”
I’ve tried to call from script…
How in the hell do i get the animations to change on a keypress right to go from Idle to Walk
I’m getting null Exception Errors. I have actually seen many tutorials and other forum posts on this.
Am i really a complete dumb ass because I’m just not getting it.
Why do i need an animation controller at all, cant i just call states based on key inputs?
Because the animation controller wants Conditions and i have no idea how to call these or change from script. for example a bool that says if the player is idle or not and how the hell to implement it???
here is my crappy newb code.
using UnityEngine;
using System.Collections;
public class movement : MonoBehaviour
{
//Myline for adjusting the clouds layer to keyb to smoothen from parallax effects
public GameObject cloudlayer;
//public float cloudmovemaintain;
public float cloudoffset;
public float TrumpWalkSpeed;
public int TrumpDirection = 0;
public GameObject trump;
Animator animation;
void start()
{
animation = GetComponent();
}
void Update()
{
Movement();
Direction();
}
void Movement()
{
if (Input.GetKey(KeyCode.RightArrow)) //RIGHT
{
//Physically Move the Sprite Right
transform.Translate(Vector2.right * TrumpWalkSpeed * Time.deltaTime); //Transform current X Right by Speed and DeltaTime
//Call the animation walking state
animation.Play(“TrumpWalk”); //WONT WORK!!! NULEXCEPTION
//Make the clouds move in proportion
cloudlayer.transform.position += Vector3.right * TrumpWalkSpeed * Time.deltaTime;
TrumpDirection = 1;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
//Physically Move the Sprite Left
transform.Translate(Vector2.left * (TrumpWalkSpeed + cloudoffset) * Time.deltaTime);
//Make the clouds move in proportion
cloudlayer.transform.position += Vector3.left * (TrumpWalkSpeed + cloudoffset) * Time.deltaTime;
//animated.transform.Rotate(0, 180, 0);
TrumpDirection = -1;
}
//TrumpDirection = 0;
}
I really do feel like a complete newb and getting so frustrated and come so far to be stuck on a simple pissant issue. Really pissing me off.
