- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
kyrinthekid · Jan 18, 2014 at 07:50 AM ·
physicscoliderphysics2d.raycast
How to use 2D box colliders with out Rigidbody2D
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public bool grounded = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Movement();
Jump();
Gravity();
}
void Jump()
{
if(Input.GetKey (KeyCode.X) && grounded == true)
{
transform.Translate(Vector2.up * 10 * Time.deltaTime);
}
}
void Gravity()
{
transform.Translate(-Vector2.up * 2 * Time.deltaTime);
}
void Movement()
{
if(Input.GetKey (KeyCode.LeftArrow))
{ transform.Translate(Vector2.right * 3 * Time.deltaTime);
transform.eulerAngles = new Vector2(0,180);
}
if(Input.GetKey (KeyCode.RightArrow))
{
transform.Translate(Vector2.right * 4 * Time.deltaTime);
transform.eulerAngles = new Vector2(0,0);
}
}
when i I added the gravity the charter clipped through the floor i know Im not that close to the answer but im fairly new to coding in general.
Comment
Use the 101010 to format your code properly so I can read it and understand it better, gets confusing like it is.
Your answer
Follow this Question
Related Questions
Look at script wrong at high speeds 0 Answers
line renderer collision detection in 3D 0 Answers
2D Raycast Layer Mask not working 1 Answer
stop vehicle from moving through walls 1 Answer
2D 360 degress platformer example needed 0 Answers