C
C#2mo ago
efeessiz

Help with error

what is this error and how to fix it
No description
31 Replies
SamwiseTheBrave
SamwiseTheBrave2mo ago
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
efeessizOP2mo ago
how to fix
SamwiseTheBrave
SamwiseTheBrave2mo ago
the error message literally says that you need to assign some object to it
efeessiz
efeessizOP2mo ago
But how..
SamwiseTheBrave
SamwiseTheBrave2mo ago
like, by drag and drop
efeessiz
efeessizOP2mo ago
im not blind i know how to read to where
SamwiseTheBrave
SamwiseTheBrave2mo ago
show me a screenshot of your ThirdPersonMovement script in inspector
efeessiz
efeessizOP2mo 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
SamwiseTheBrave2mo ago
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
efeessizOP2mo ago
cant see public transform cam @WinForms Sam
SamwiseTheBrave
SamwiseTheBrave2mo ago
show me a screenshot from Unity where your script shows
efeessiz
efeessizOP2mo ago
No description
efeessiz
efeessizOP2mo ago
this?
SamwiseTheBrave
SamwiseTheBrave2mo ago
yes]
efeessiz
efeessizOP2mo ago
alr what now
SamwiseTheBrave
SamwiseTheBrave2mo ago
here
No description
SamwiseTheBrave
SamwiseTheBrave2mo ago
you have empty field for cam and for character controller
efeessiz
efeessizOP2mo ago
what do I do oh nvm cant change controller tho I can only change cam
SamwiseTheBrave
SamwiseTheBrave2mo ago
do you have a character controller?
efeessiz
efeessizOP2mo ago
cam is falling down when I run it no I just added
SamwiseTheBrave
SamwiseTheBrave2mo ago
check if you did everything as he did in tutorial
efeessiz
efeessizOP2mo ago
the cam is moving when I do wasd and its lagging when I do it I think I did.....
SamwiseTheBrave
SamwiseTheBrave2mo ago
you obviously did not since it's not working
efeessiz
efeessizOP2mo ago
can u add me so I can create a groupchat with my frien and he can screen share
SamwiseTheBrave
SamwiseTheBrave2mo ago
sorry, but I don't have that much time
efeessiz
efeessizOP2mo ago
ugh I straight copied the code that the tutorial man mentioned
SamwiseTheBrave
SamwiseTheBrave2mo ago
check if you assigned right camera and see if he perhaps did something more
efeessiz
efeessizOP2mo ago
do you want me to send any kind of ss cause I can barely understand
SamwiseTheBrave
SamwiseTheBrave2mo ago
watch what he did step by step I can't really help more, sitting here, miles away
Buddy
Buddy2mo 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