This is my current script, doing a 2D simple platform game and this is the first time I have used unity, using a c# script, thanks for any help! PS some of my script has been cut of below for some reason :s
using UnityEngine;
using System;
public class Movement2D : MonoBehaviour {
//Controls Player Movement
public float movementSpeed = 25.0f;
//Controls Player Jump
private int jumpHeight = 600;
public bool isGrounded = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//Controls Player Left Movement
if (Input.GetKey ("left") || Input.GetKey ("a")) {
transform.position -= Vector3.right * movementSpeed * Time.deltaTime;
}
//Control Player Righ Movement
if (Input.GetKey ("right") || Input.GetKey ("d")) {
transform.position += Vector3.right * movementSpeed * Time.deltaTime;
}
if (Input.GetButtonDown ("Jump") && isGrounded) {
Jump ();
}
}
void Jump (){
if(!isGrounded){
return;
}
isGrounded = false;
rigidbody.AddForce(new Vector3(0, jumpHeight,0), ForceMode.Force);
}
void FixedUpdate(){
isGrounded = Physics.Raycast(transform.position, -Vector3.up, .5f);
}
}