Another Error Again


Sorry about all the errors lately, but this one I can make 0 sense of. I don’t see anybody else having this issue, and when I looked on the updated site for it, it was the same as my code.
{

Rigidbody rb;

// Start is called before the first frame update

void Start()

{

    rb = GetComponent<Rigidbody>();

}

// Update is called once per frame

void Update()

{

    ProcessThrust();

    ProcessRotation();

}



void ProcessThrust()

{

   if(Input.GetKey(KeyCode.Space))

   {

       rb.AddRelativeForce(Vector3.up);

   }

}

void ProcessRotation()

{

     if (Input.GetKey(KeyCode.A))

   {

       Debug.Log("rotate left");

   }

    else if (Input.GetKey(KeyCode.D))

   {

       Debug.Log("rotate right");

   }

}

@Nina Are you able to help me with this?

You don’t see these kinds of errors often on code samples this simple. Sometimes it’s the compiler getting confused. If that’s the case, shut down unity and your code editor and reopen them and see if that works.

If not:

Do you have
using UnityEngine;

In your code?

using System.Numerics;

In your code?

You should have the first. If you also have the second, you’ll want to replace Vector3 with UnityEngine.Vector3 (so it’s clarified which version you are using) on line 29, where you’ve used it (and perhaps in other lines if it continues to complain).

Outside that, I’m not sure.

UnityEngine.Vector3 worked!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms