Question by
cliffmlimwa · Aug 23, 2018 at 01:25 PM ·
rigidbody2dkinematic
Rigdbody upforce
i have following code i set a rigdbody of the ball kinematic into inspector, when i touch screen a ball go down look like up force doesn't work
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallController : MonoBehaviour {
public float UpForce;
Rigidbody2D rb;
bool Started;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody2D> ();
Started = false;
//rb.angularDrag = 0;
}
// Update is called once per frame
void Update () {
if (!Started) {
if (Input.GetMouseButtonDown (0)) {
Started = true;
rb.isKinematic = false;
} else {
if (Input.GetMouseButtonDown (0)) {
rb.velocity = Vector2.zero;
rb.AddForce(new Vector2(0,UpForce));
}
}
}
}
}
its work in unity old version whats i can do?
Comment
Your answer
Follow this Question
Related Questions
How can I move a Kinematic Rigidbody2d along the x-axis? 1 Answer
Prevent Player from passing through walls 1 Answer
Kinematic 2D Rigidbody movement: Rigidbody2D.MovePosition vs Rigidbody2D.position problem 1 Answer
How do I keep rigidbodies from pushing each other? 2 Answers
Making a Dynamic Rigidboy NOT move on a specific condition 0 Answers