Unity Vector 3 not recognized

Asked 2 years ago, Updated 2 years ago, 77 views

This is my first time asking a question here, so I'm sorry if there are any mistakes or difficulties.

I am currently using Unity 5.4.3 and I am creating an animation with script.
As a flow, read the value from the sensor of Arduino → Calculate the value → Read the current location of the moving object A → Move A by the calculated value → Draw
It's like this.

We have verified that the sensor values are read and calculated (one line at a time), but we cannot read the current location of A below.
There is a possibility that the Vector 3 model does not exist on Monodevelop, or that A is not recognized, but I am having trouble knowing how to confirm it and what the cause is. Could someone help me?

Here are some excerpts from the program:

public Vector3 poshand;
void Start() {
    poshand = new Vector3();
}

void Update() {
    progressstime+=Time.deltaTime;
    if(progressstime>=0.25){
        portRead();
        progressstime = 0f;
    }
}

public void portRead() {
    if(port1!=null&port1.IsOpen){
        // Arduino sensor reading and calculating values around here (not shown because it is long
       try{
            handmoves(myData_proxensor);
        }catch(System.Exceptione){
            textobj.GetComponent<UnityEngine.UI.Text>().text="Verror";
        }
    }
}
  public void handmoves(intard_parameter) {
    poshand=shakeshand.transform.position;// Error here
    poshand.x - =ard_parameter/5;
    shakeshand.transform.position=poshand;// Error here
  }

c# unity3d

2022-09-30 21:21

1 Answers

It doesn't include the declaration part of shakeshand, so I have a hunch. I don't think this is a GameObject.

Or if "shakeshand" is a node name, not a variable,
If you replace it with gameObject.transform.position, no errors appear.

If there is an error, read the error message carefully or
At the very least, including error messages in your questions will make the situation easier to understand.


2022-09-30 21:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.