Please re-add the code example using code tags. This adds syntax highlighting and allows for proper indentations. There are probably a couple missing brackets somewhere, but as it is now it’s hard to spot.
One thing for now GetButtonDown(“w” + “left shift”) is not a thing. You’d rather check for GetButton(KeyCode.LeftShift) and inside that you check for GetButtonDown(KeyCode.W).
Edit: One more thing i just noticed, all the way down you write collision,gameobject.tag. The comma there is responsible for at least one error, it got to be a dot. And gameobject does not exist, it’s gameObject instead. Programming is case sensitive, you cant just write things down “somewhat similar” and expect them to work
Ok, so maybe i worded that a bit badly. But the Input check for two keys should look like this:
if(Input.GetKey(KeyCode.LeftShift)){ // <-- note how this is GetKey
if(Input.GetKeyDown(KeyCode.W)){ // <-- and this GetKeyDown
// Do stuff supposed to happen when LShift + W is pressed once
}
}
Afterwards (some mentioned above in my edit):
line 53: the comma needs to be a dot
line 53: gameobject needs to be gameObject
line 51: onCollisionEnter does not exist, OnCollisionEnter does. Currently you are declaring your own new onCollisionEnter method, which is fine, but wont be called by Unity, which you intend.
This the above and then let’s see the updated code and the new / remaining error messages
this is the new code (if i got it right) and errors:
Assets\scripts\controller\Movement.cs(17,10): error CS0111: Type ‘Movement’ already defines a member called ‘Start’ with the same parameter types
Assets\RagdollDeath.cs(8,6): error CS0246: The type or namespace name ‘SerializedFieldAttribute’ could not be found (are you missing a using directive or an assembly reference?)
Assets\RagdollDeath.cs(8,6): error CS0246: The type or namespace name ‘SerializedField’ could not be found (are you missing a using directive or an assembly reference?)
Assets\scripts\RagdollDeath.cs(8,2): error CS0246: The type or namespace name ‘SerializedFieldAttribute’ could not be found (are you missing a using directive or an assembly reference?)
Assets\scripts\RagdollDeath.cs(8,2): error CS0246: The type or namespace name ‘SerializedField’ could not be found (are you missing a using directive or an assembly reference?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
float Speed;
public Rigidbody rb;
public bool PlayerOnGround = true;
private void Start()
{
rb = GetComponent<Rigidbody>();
}
// Start is called before the first frame update
void Start()
{
Speed = 5;
}
// Update is called once per frame
void Update()
{
transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime * Speed, 0, Input.GetAxis("Vertical") * Time.deltaTime * Speed);
if(Input.GetKey(KeyCode.UpArrow)) {
transform.Translate(5, 0, 10 * Time.deltaTime);
}
if(Input.GetKey(KeyCode.DownArrow)) {
transform.Translate(5, 0, -10 * Time.deltaTime);
}
if(Input.GetKey(KeyCode.LeftArrow)) {
transform.Translate(-10 * Time.deltaTime, 0, 0);
}
if(Input.GetKey(KeyCode.RightArrow)) {
transform.Translate(10 * Time.deltaTime, 0, 0);
}
if(Input.GetButtonDown("w")) {
if(Input.GetButtonDown("left shift")){
transform.Translate(10 * Time.deltaTime * 3f, 0, 0);
}
}
if(Input.GetButtonDown("jump") && PlayerOnGround)
{
rb.AddForce(new Vector3(0, 5, 0), ForceMode.Impulse);
PlayerOnGround = false;
}
}
private void OnCollisionEnter(Collision collision)
{
if(collisionn.gameObject.tag == "ground")
{
PlayerOnGround = true;
}
}
}
[code]
The error message is pretty much telling you what is wrong. The type “Movement” which you defined, already has a “Start()” function. Meaning you got two. At line 13 and 18. You cant have the same method twice.
If the compiler tells you that it can not find something, then it’s either not imported, or you included a typo. In this case (and oftentimes for beginners, so double check!) it’s the latter. https://docs.unity3d.com/ScriptReference/SerializeField.html
“SerializeField” not “SerializedField”
As for the other errors in the RagdollDeath script, they may be follow-errors by the already confused compiler. They imply that you got stuff twice again, which you dont. So fix the above first and then check if these errors still exist.
On that note tho, line 45 in your RagdollDeath script you write collider.enavled which does not exist. You mean enabled. Try to avoid typos like these. They are easy to spot but can be pretty irritating when getting started.