Jump Issue :(
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 :)
[1]: /storage/temp/99050-1.png
Answer by PersianKiller · Aug 03, 2017 at 04:36 AM
your code is ok but your circle collider is trigger and that's why your character is falling down
uncheck Is Trigger
Reason: "Is Trigger" disables physics and velocity manipulations depend on physics.