- Home /
This question was
closed Mar 03, 2020 at 02:26 PM by
tormentoarmagedoom for the following reason:
Too subjective and argumentative
Question by
unity_QVXld_cz_-HMRA · Mar 03, 2020 at 02:19 PM ·
scripting problemsprite
How to make jump NO FLY in 2d ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public float moveSpeed;
public float jumpHeight;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.W))
GetComponent<Rigidbody2D>().velocity = new Vector2(0, jumpHeight);
if (Input.GetKey(KeyCode.D))
GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
if (Input.GetKey(KeyCode.A))
GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
}
}
Comment
Answer by tormentoarmagedoom · Mar 03, 2020 at 02:26 PM
Hello.
Bad post.
Explain what you want, what you tried, what is not working, what you exepct, what did you find on google..
Dont just make a title of 6 words and paste your code. e are not your teachers.
Post closed. Remake it.
Bye.