Home > other >  New preparation and call for help on c # method in Unity
New preparation and call for help on c # method in Unity

Time:12-30

Recently learned c #, then the method to add this public or private, before writing a call is not static can not directly call, to Mr Into a class object, through ". The suffix "call again, but to see the script in the Unity as are directly declare a function, is taken directly inside the undate, method also didn't access modifiers, such as this
 
Void the Update () {
Control ();
}
Void Control () {
//define three value control mobile
Float xm=0, ym=0, zm=0;
//gravity
Ym -=m_gravity * Time. DeltaTime;
//move around
If (Input. GetKey (KeyCode. W)) {
Zm +=m_movSpeed * Time. DeltaTime;
} else if (Input GetKey (KeyCode. S)) {
Zm -=m_movSpeed * Time. DeltaTime;
}
If (Input. GetKey (KeyCode. A)) {
Xm -=m_movSpeed * Time. DeltaTime;
} else if (Input GetKey (KeyCode. D)) {
Xm +=m_movSpeed * Time. DeltaTime;
}
//use Move function provided by the character controller for mobile
M_ch. Move (m_transform. TransformDirection (new Vector3 (xm, ym, zm)));
}

Want to ask why is this

CodePudding user response:

If a method does not add the modifier, the default to private private, just you can't see,

CodePudding user response:

references on 1/f, deep and remote wind's response:
if the method does not add the modifier, the default for private private, just you can't see,

Thank you, that this function, as long as it is in his class, function can use directly

CodePudding user response:

refer to the second floor weixin_46248763 response:
Quote: reference, 1/f, deep and remote wind month response:
if the method does not add the modifier, the default for private private, just you can't see,

Thank you, that this function, as long as it is in his class, function can directly use ah

Right, private members, class can be used directly,
  • Related