- Home /
This question was
closed Mar 18, 2017 at 10:15 PM by
Rehtt.
Question by
Rehtt · Feb 22, 2017 at 08:29 AM ·
2d-platformer
Trying to make a 2d platform when suddenly?!?!?!
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
Follow this Question
Related Questions
2.5D Platformer - Jump Question 1 Answer
The main camera pans up when I press play.Please help. 0 Answers
Line Renderer. How to lock z axis for side scroller? 1 Answer
[2D] Check if player is on the ground 4 Answers
Trouble with Jumping Algorithm 1 Answer