#Camera Transform Forward Not Consistent
1 messages · Page 1 of 1 (latest)
Making into thread to not clog
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
One of them shoots no ray, and the other shoots in the world x direction
Camera Transform Forward Not Consistent
did you try debugging the values of all your variables?
camera.transform.forward, camera.transform.position, rayStartPos, rayShootDir?
Yeah, with DrawRay
The one that isn't commented out at least has a ray
The one that is commented out has no ray at all.
no, have it actually print the values into the console with Debug.Log
let's confirm that it actually has the values you think it has
Okay, for it, the direction of camera.transform.forward is always (0, 0, 1), and the position never changes
okay, and is your camera actually moving?
Yeah, I have a charactercontroller in first person that I use, and it moves with it
can you show the BasePlayer script?
yeah sure
and moves with it how? as a child? Did you write a script? Cinemachine?
The camera is just a child of the player
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
can you screenshot the inspector for the player?
when you click on the camera in the Camera slot on BasePlayer, what does it highlight?
does it highlight a camera in your assets folder, by any chance? On a prefab?
It highlights the Camera object in the inspector
The one right under the Player
hmmm
yeah been stuck on this for a while now
can you change it from new Camera camera to something that doesn't need the new keyword? Like Camera playerCam or w/e
now this is interesting
You probably need to assign the cam variable of the BasePlayer script in the inspector.```
even when it is assigned
try dragging your Player GO into all the fields that take BasePlayer again
Okay, that was because of not applying something, back to the same issue of the direction and position not changing
So it wasn't because of the new keyword
sorry, can you clarify? Not applying what?
it could be relevant to the problem
I hadn't applied a prefab change, so it didn't know that the player's camera had been assigned
I have one more idea
How do I "unprefab" something?
Like the player?
It could be just reading the position of the prefab in the files?
hold on, one of my big suspicions is that it is referencing the prefab (in the assets folder) rather than the instance in the scene. So I think this is related
oooh okay
right click on the version in the scene and click unpack prefab
but also
when you're dragging stuff in you have to make sure you're dragging from the right place
so you could open up the prefab assets and hook everything up internally there
or you could go into the scene and hook everything up between objects from the scene
but make sure you don't take anything from the assets folder doing it that way
Or I guess I could just have the script reference camera.main since it needs the player camera
haha yep, that could work as well
like cache it at start
or get the camera with GetComponentInChildren
oh yeah that would probably be better
though I think the problem is you're grabbing PlayerBase from the prefab asset
yeah i see that now
so you'd want to get that with a GetComponent as well, which might be trickier