Question by
Rehtt · Feb 21, 2017 at 08:50 PM ·
2d platformer
Trying to make a 2d platformer and I'm having problems with the script.
The script works goes through and all that but my character doesn't jump. YAY!!! heres the script
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Player_Movement : MonoBehaviour { public float speed =150f; public float jumpPower =150f; public bool jump = false; public bool grounded; private Rigidbody2D rb2d;
// Use this for initialization
void Start ()
{
rb2d = gameObject.GetComponent<Rigidbody2D> ();
// float L = Input.GetAxis("Vertical");
}
void update ()
{
if (Input.GetKeyDown (KeyCode.V)) { //("space"))
// jump = true;
//rb2d.AddForce (Vector2.up * speed);
rb2d.AddForce (Vector2.up * jumpPower * Time.deltaTime);
}
/* if (jump == true) {
rb2d.AddForce ((Vector2.up * speed) * L);
/Transform.Translate.up;
}
*/
}
void FixedUpdate()
{
float h = Input.GetAxis("Horizontal");
rb2d.AddForce ((Vector2.right * speed) * h);
}
}
Comment
Your answer
Follow this Question
Related Questions
A little bit of help with jump 2 Answers
what is the most efficient way to create a map for a 2D endless runner? 0 Answers
2D Object Pickup - Occasionally adding score twice 0 Answers
Character hits invisible ghost collision when jumping against objects while pushing against them 0 Answers
Double Jump Not Working 0 Answers