G’day,
I am trying to make a game and I require the ability to Jump, I have viewed a couple YouTube tutorials without any luck, I have written the code I will post below. The console tells me;
error CS0542: ‘Jump.Jump()’: member names cannot be the same as their enclosing type
Although when overlooking my code, I can not see what this error is talking about, this code is also the same as what was done on youtube.
So I’m looking to find out what is this issue, and any other issue I may occur with making this jump script…
using UnityEngine;
using System.Collections;
public class Jump : MonoBehaviour {
//Speed
public float movementSpeed = 5.0f;
//Controls Player Jump
private int jumpHeight = 500;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Jump") || Input.GetKey ("w")) {
Jump();
}
}
void Jump (){
Rigidbody.AddForce(new Vector3(0, jumpHeight,0), ForceMode.Force);
}
}
Thanks, I hope I can get a little help!
P.S, Any great tutorials how to make a sliding background for an infinitive runner…