Help Needed Cannot Jump 3D Object

Hi everyone, as you can guess im Beginner to coding and Unity. I merged few codes but I couldnt figure out how to solve jumping. When I change Y value its keeps moving constantly according to jump speed. Can some one give me a hand?

XXXXXXXXXXXXXXXXXXXXXXXX

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class CC : MonoBehaviour
{

public float speed;
public Text countText;
public Text winText;
//
public Vector3 jump;
public float jumpForce = 2.0f;

public bool isGrounded;
//
private Rigidbody rb;
private int count;

void Start()
{
rb = GetComponent();
count = 0;
SetCountText();
winText.text = “”;
//
jump = new Vector3(0.0f, 2.0f, 0.0f);
//
}
void OnCollisionStay()
{
isGrounded = true;
}

void FixedUpdate()
{
float moveHorizontal = Input.GetAxis(“Horizontal”);
float moveVertical = Input.GetAxis(“Vertical”);
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
//
{
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
{
if (transform.position.y <= 1.05f)
{
rb.AddForce(jump * jumpForce, ForceMode.Impulse);
isGrounded = false;
}
}
}
//
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag(“Capsule”))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}
void SetCountText()
{
countText.text = "Count: " + count.ToString();
if (count >= 3)
{
winText.text = “You Win!”;
}
}
}

Please use code tags: Using code tags properly

How to report problems productively in the Unity3D forums:

http://plbm.com/?p=220

Help us to help you.

1 Like

Thank you very much! I reposted as you said.