- Home /
Question by
Nano-Additcs · Jul 27, 2014 at 05:43 AM ·
animationcontrol
How can I control an animated character?
Hi Everyone,
I am just learning how to create basic games and bucking the trend (joke) by starting with a Flappy Bird imitation.
I have created a bird and animated it so that the wings flap. Does anyone know how I can control this bird so that it moves up when I hit the spacebar?
I can do it to non animated characters using the following script:
using UnityEngine; using System.Collections;
public class PlayerControl : MonoBehaviour {
// Use this for initialization
void Start () {
}
// The force which is added when the player jumps
// This can be changed in the Inspector window
public Vector2 jumpForce = new Vector2(0, 300);
// Update is called once per frame
void Update ()
{
// Jump
if (Input.GetKeyUp("space"))
{
rigidbody2D.velocity = Vector2.zero;
rigidbody2D.AddForce(jumpForce);
}
}
}
Thanks
Comment
Best Answer
Answer by Nano-Additcs · Jul 27, 2014 at 04:44 AM
Found the answer here --> https://www.youtube.com/watch?v=He6-gyfVUGI
and here ---> https://www.youtube.com/watch?v=eOkfDjMWut4