Dear all,
I am a new user of unity and trying to make a very simple game,
my issue is, , i want to make a player jumps when i click the left click on mouse or jump button, As per code below
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour {
public Rigidbody2D Ball;
public float jumpforce = 10f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("jump") || Input.GetMouseButtonDown(0))
Ball.velocity = Vector2.up * jumpforce;
}
}
i set allthe necessary things in attached image, and the player still falling down, and when i put the gravity to zero, it holds in the middle of the screen with no move
Please help and thanks