Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

I need help with control.

$
0
0
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); } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>