Movement input

Hi there

im sort of new to this whole thing, decided to try to use some of the tutorials to get an idea.

So doing the roll-a-ball thing right now. finished most of it just having trouble with moving the ball. I don’t know how to set up my input command. Sure i got one from the asset store, but made no difference.

Help.

Kind regards

Hey,

Can you post an example of what you are doing? It’s not clear to me where you are needing a hand.

Cheers

Ill clear it up a bit then.

Earlier today i was working on the script for the game to get ball to roll, i had a few issues by i managed to get them fixed later. After i finished the scrip, the ball was supposed to move. When ever i try to play test it the console tells me that there is a problem on line 21. Now i am not sure what that problem is but ill post the message along with the scrip.

NullReferencEexception: object reference not set to an instance of an object.

Maybe a pair of experienced eyes will see more than I.

2888080–212235–PlayerControler.cs (517 Bytes)

Hi,

from the exception message I can surmise that its like you have are trying to use an object that doesn’t exist at the time line 21 executes.

This can usually occur with one of the following:

  • You have a public/ or serialized private variable exposed to the inspector window but haven’t dragged a reference to the object into it in the editor.
  • You are using a GameObject.Find style method to find an object that doesn’t exist at the moment.

If you can debug the script or place a Debug.Log([object]) before the line in the code that its complaining about it should reveal the problem.

Steps I would take would be:

  • Identify which object is null through debugging (or Debug.Log()s).
  • Find out how it should be made available (either through the inspector window or from script)
  • Correct it by dragging the object into the slot or making it available to do so

I’m not familiar with the ball roll code base but if you need further help, if you can post the code you’ve written I should be able to help further.

Kind Regards,

Apologies, just noticed that you’ve already posted the code, I’ll have a look.

Looking at your code, the PlayerControler object needs a RigidBody component to move.

I believe its because you have used a lowercase “void start()” method. In c# methods are case sensitive. Unity will be looking to use “void Start()” to initialize your object. So your code that gets the Rigidbody component is likely not running.

Either that or there is no Rigidbody component attached to PlayerControler in the editor.

Kind Regards,

Thx

Ill try that.

Ok, now i think i am getting to the root of the problem, which apparently is rb and ‘;’ being recognized as an unexpected symbol. This seems to prevent the whole script from running. I got a few ideas as to why this is happening and will try to fix it.

I am open to suggestions.

Thx for you help Mr.Jobot.
I found the error that was preventing my object to move. i mistyped the script for Rigidbody as private instead of public. it works now.

Kind regards

No problem at all.

Its strange that private caused the problem as that should still be fine in the context of your code. Perhaps an illegal character was pasted in that caused the issue and it was fixed by removing it and typing public.

Regardless, glad its now working for you

Kind Regards,

I did a tutorial on third person player and camera movement. You can view it here.

http://profuse.weebly.com/blog/player-and-camera-movement-tutorial-007

You may want to back track a few lessons if you’re an absolute beginner. There is a sample project available as well. This is the same scripting I used for this.

Is there any tutorials or assets to allow a non-biped 3rd person controller? Namely, I want a CAT to be the third person character. I chose Cu-Cat2 as the cat asset.

How would I make a 3rd person camera that would follow the animated cat around and allow the player to use the mouse and keyboard to control it?

Does such an asset or tutorial exist?

Thank you.

Mike