Bobblehead wars problem

Hi Guys can anyone help please I’ve been stuck on this problem for hours I’ve been doing the camera movement
section in the book page 78 I’m doing everything the book says but keep getting this error
Assets/Scripts/CameraMovement.cs(17,14): error CS0120: An object reference is required to access non-static member `UnityEngine.Transform.position’ I have nt got a clue what to do the book is not helping thanks from steve

@vegetarianzombie can you please help with all of this when you actually get a chance after all? Thank you - much appreciated! :]

can you help with this error i keep getting

Can you post what you currently have in CameraMovement.cs?

Hi fusetech thanks for your reply I’m on page 80 in the unity by tutorials book heres a screen shot of the camera movement ss thanks from steve

I’m not positive this is the issue, but you appear to be missing a closing curly brace.

void Update () {
    if (followTarget != null) {
      transform.position = Vector3.Lerp(transform.position, followTarget.transform.position, Time.deltaTime * moveSpeed);
    }  //This was the one that was missing
  }

Hi Fusetech thanks for your help sorry for late reply been on holiday it seems to work now but I’m having a lot of trouble with the unity games book i do what the book says but keep on getting errors the code I’ve just done is this and this is the error i keep getting

Line 17 should be characterController (Your instance of the class), rather than CharacterController (The class).

We have all been at that phase where a simple typo from a tutorial causes hours of headaches and frustration. My advice is to just stick it out and keep practicing! Soon you will be able to look at the errors from Unity and be able to spot the issues. It gets better.

Thanks fushtech thanks for your help and advice i really appreciate it thanks steve

HI fuse tech sorry to bother you again if you’ve got time could you please check this code for me i can’t find the problem sorry if I’m being a pain but learning to code can cause sleepless nights thanks steve

No problem Steve. Happy to help.

If you look at the error from the console, it is telling you the error is around line 51 of PlayerController.cs.

The screenshot cuts off at line 50… so I’m assuming there isn’t anything below that line. If that is true, then this error is telling you that you are missing a closing curly brace.

Try adding a } on line 50 and see if that resolves it for you.

This topic was automatically closed after 166 days. New replies are no longer allowed.