Im trying to do a 2D side scrolling game similar to the Mario swimming level. I only want him to swim straight up and have gravity to pull him back down, no left or right option. I have a script tied to an animation but its activated by speed. Any help would be appreciated! Thank you, here is the script so far... FYI Im an absolute beginner.
using UnityEngine;
using System.Collections;
public class FishControllerScript : MonoBehaviour {
public float maxspeed = 10f;
bool facingRight = true;
Animator anim;
void Start () {
anim = GetComponent ();
}
void FixedUpdate () {
float move = Input.GetAxisRaw ("Vertical");
anim.SetFloat ("Speed", Mathf.Abs (move));
rigidbody2D.velocity = new Vector2 (move * maxspeed, rigidbody2D.velocity.x);
}
}
↧