C
C#2w ago
efeessiz

Help with error

what is this error and how to fix it
No description
31 Replies
SamwiseTheBrave
you did not assign any object to a public field in inspector aka you have a public variable that's visible in inspector but it's empty
efeessiz
efeessiz2w ago
how to fix
SamwiseTheBrave
the error message literally says that you need to assign some object to it
efeessiz
efeessiz2w ago
But how..
SamwiseTheBrave
like, by drag and drop
efeessiz
efeessiz2w ago
im not blind i know how to read to where
SamwiseTheBrave
show me a screenshot of your ThirdPersonMovement script in inspector
efeessiz
efeessiz2w ago
k one min using System.Collections; using System.Collections.Generic; using UnityEngine; public class ThirdPersonMovement : MonoBehaviour { public CharacterController controller; public Transform cam; public float speed = 6f; public float turnSmoothTime = 0.1f; float turnSmoothVelocity; void Update() { float horizontal = Input.GetAxisRaw("Horizontal"); float vertical = Input.GetAxisRaw("Vertical"); Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized; if (direction.magnitude >= 0.1f) { float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y; float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime); transform.rotation = Quaternion.Euler(0f, angle, 0f); Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward; controller.Move(moveDir.normalized * speed * Time.deltaTime); } } }
SamwiseTheBrave
public Transform cam; this field is visible in inspector by inspector I mean in Unity you have to grab object representing your camera and drag it to this field in Unity if you're following a tutorial it should be shown there
efeessiz
efeessiz2w ago
cant see public transform cam @WinForms Sam
SamwiseTheBrave
show me a screenshot from Unity where your script shows
efeessiz
efeessiz2w ago
No description
efeessiz
efeessiz2w ago
this?
SamwiseTheBrave
yes]
efeessiz
efeessiz2w ago
alr what now
SamwiseTheBrave
here
No description
SamwiseTheBrave
you have empty field for cam and for character controller
efeessiz
efeessiz2w ago
what do I do oh nvm cant change controller tho I can only change cam
SamwiseTheBrave
do you have a character controller?
efeessiz
efeessiz2w ago
cam is falling down when I run it no I just added
SamwiseTheBrave
check if you did everything as he did in tutorial
efeessiz
efeessiz2w ago
the cam is moving when I do wasd and its lagging when I do it I think I did.....
SamwiseTheBrave
you obviously did not since it's not working
efeessiz
efeessiz2w ago
can u add me so I can create a groupchat with my frien and he can screen share
SamwiseTheBrave
sorry, but I don't have that much time
efeessiz
efeessiz2w ago
ugh I straight copied the code that the tutorial man mentioned
SamwiseTheBrave
check if you assigned right camera and see if he perhaps did something more
efeessiz
efeessiz2w ago
do you want me to send any kind of ss cause I can barely understand
SamwiseTheBrave
watch what he did step by step I can't really help more, sitting here, miles away
Buddy
Buddy2w ago
Do not blindly copy paste That's how you get stuck in tutorial-hell Understand what the code does. Also, do not learn C# in Unity. Please. I suggest learning by doing, $helloworld is a good start.
Want results from more Discord servers?
Add your server