#Camera Transform Forward Not Consistent

1 messages · Page 1 of 1 (latest)

vapid jolt
#

Making into thread to not clog

#

One of them shoots no ray, and the other shoots in the world x direction

#

Camera Transform Forward Not Consistent

elder carbon
#

did you try debugging the values of all your variables?

#

camera.transform.forward, camera.transform.position, rayStartPos, rayShootDir?

vapid jolt
#

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.

elder carbon
#

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

vapid jolt
#

Okay, for it, the direction of camera.transform.forward is always (0, 0, 1), and the position never changes

elder carbon
#

okay, and is your camera actually moving?

vapid jolt
#

Yeah, I have a charactercontroller in first person that I use, and it moves with it

elder carbon
#

can you show the BasePlayer script?

vapid jolt
#

yeah sure

elder carbon
#

and moves with it how? as a child? Did you write a script? Cinemachine?

vapid jolt
#

The camera is just a child of the player

elder carbon
#

can you screenshot the inspector for the player?

vapid jolt
elder carbon
#

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?

vapid jolt
#

It highlights the Camera object in the inspector
The one right under the Player

elder carbon
#

hmmm

vapid jolt
#

yeah been stuck on this for a while now

elder carbon
#

can you change it from new Camera camera to something that doesn't need the new keyword? Like Camera playerCam or w/e

vapid jolt
#

now this is interesting

#
You probably need to assign the cam variable of the BasePlayer script in the inspector.```
even when it is assigned
elder carbon
#

try dragging your Player GO into all the fields that take BasePlayer again

vapid jolt
#

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

elder carbon
#

it could be relevant to the problem

vapid jolt
#

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?

elder carbon
vapid jolt
#

oooh okay

elder carbon
#

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

vapid jolt
#

Or I guess I could just have the script reference camera.main since it needs the player camera

elder carbon
#

haha yep, that could work as well

vapid jolt
#

like cache it at start

elder carbon
#

or get the camera with GetComponentInChildren

vapid jolt
#

oh yeah that would probably be better

elder carbon
#

though I think the problem is you're grabbing PlayerBase from the prefab asset

vapid jolt
#

yeah i see that now

elder carbon
#

so you'd want to get that with a GetComponent as well, which might be trickier

vapid jolt
#

any idea why my source file can't be found now lol?
I just changed the start function

#

oh never mind unity being unity just restarted the editor

#

thanks by the way for the second pair of eyes