CameraNodem Problem

Hi Guys,



I’d love it if somebody could please help me fix this annoying problem.

To start off, in my scene graph there is but one node which is my playable character. He can jump, walk and has a standing pose which correspond to the ‘J’, ‘G’ and ‘H’ keys respectively. Now I want to have a camera behind him constantly following him as he moves and so I followed the “Making the Camera Follow a 3rd-Person Character” tutorial and decided to use the CameraNode because it seemed appropriate. My problem here is that when I copy the code for the CameraNode and alter it in such a way that it is attached to my player Node, a certain portion of the code fails me. That line of the code is the “camNode.setControlDir(ControlDirection.SpatialtoCamera);” specifically the ‘setControlDir’ method which is underlined in red. So when I hover my mouse over ‘setControlDir’, it gives a message saying “cannot find symbol

symbol: method setControlDir(ControlDirection)

location: variable camNode of type Node”

I have no idea on how to fix this so if someone could please help me out, I’d greatly appreciate it :slight_smile:

Thank you in advance,

Dan.

@floevomojobo said:
Hi Guys,

I'd love it if somebody could please help me fix this annoying problem.
To start off, in my scene graph there is but one node which is my playable character. He can jump, walk and has a standing pose which correspond to the 'J', 'G' and 'H' keys respectively. Now I want to have a camera behind him constantly following him as he moves and so I followed the "Making the Camera Follow a 3rd-Person Character" tutorial and decided to use the CameraNode because it seemed appropriate. My problem here is that when I copy the code for the CameraNode and alter it in such a way that it is attached to my player Node, a certain portion of the code fails me. That line of the code is the "camNode.setControlDir(ControlDirection.SpatialtoCamera);" specifically the 'setControlDir' method which is underlined in red. So when I hover my mouse over 'setControlDir', it gives a message saying "cannot find symbol
symbol: method setControlDir(ControlDirection)
location: variable camNode of type Node"
I have no idea on how to fix this so if someone could please help me out, I'd greatly appreciate it :)
Thank you in advance,
Dan.


Haven't looked through the tutorial, but there is a difference between the default cam, FlyCam and ChaseCam. Make sure you are using the appropriate camera.

@ t0neg0d

Hey man, thanks for your reply but I’ve disabled the flycam already and I’m just having trouble using “setControlDir”.

Dan.

@floevomojobo said:
@ t0neg0d
Hey man, thanks for your reply but I've disabled the flycam already and I'm just having trouble using "setControlDir".
Dan.


I've never used the CameraNode, however a bit further down on the page is the information about ChaseCam. This one I have used... and it works well. Is there something the CameraNode does that the ChaseCam doesn't?

It is easy to set up the Chase cam to mimic you player control rotation, if that is the difference. Let me see if I can find an example...

Looks like I handled this in reverse… but it gives the basic idea.



[java]

Quaternion qrt = new Quaternion(

charNode.getLocalRotation().getX(),

cam.getRotation().getY(),

charNode.getLocalRotation().getZ(),

cam.getRotation().getW()

);[/java]



Then use this to set the character nodes rotation. This allows you to rotation the camera up and down focused on the player only effecting the characters Y rotation. I did it this way because I didn’t see a reason for reinventing the wheel to switch from first person to chase cam mode.



If your character can swim as well… you want to grab the cam’s X/Z rotation as well when swimming.

@t0neg0d said:
Looks like I handled this in reverse... but it gives the basic idea.

[java]
Quaternion qrt = new Quaternion(
charNode.getLocalRotation().getX(),
cam.getRotation().getY(),
charNode.getLocalRotation().getZ(),
cam.getRotation().getW()
);[/java]

Then use this to set the character nodes rotation. This allows you to rotation the camera up and down focused on the player only effecting the characters Y rotation. I did it this way because I didn't see a reason for reinventing the wheel to switch from first person to chase cam mode.

If your character can swim as well... you want to grab the cam's X/Z rotation as well when swimming.

Wow Thank you soo much for this but I'm very very new to JME3 but i'm not sure what you mean when you say " Then use this to set the character nodes rotation". I mean, what exactly do I do with the code you've given me?

PS: Thank you soooooo much for bearing with me
Dan
@floevomojobo said:
location: variable camNode of type Node"

This is wrong. camNode should be a CameraNode not a Node.
make sure its properly instantiated with the proper type.
@nehon said:
This is wrong. camNode should be a CameraNode not a Node.
make sure its properly instantiated with the proper type.

Thank you sir, I'll fix it right away :)

Dan.
@nehon said:
This is wrong. camNode should be a CameraNode not a Node.
make sure its properly instantiated with the proper type.

THANK YOU SOOOO MUCH NEHON!! MUCH APPRECIATED :D