New Camera component , WASD keys

I want to move the camera with the WASD keys in new camera component,
I activate them and then use them but nothing happens, is there some trick?
thank you :slight_smile:

The camera viewport needs to have the keyboard focus for the WASD keys to work so that might be interfering.

Are you trying to move the camera directly in the node viewer, or in a floating window or a perform window? Even if the node is selected (with the green outline) and active, you might need to also left-click in the node viewport to give the keyboard focus to the viewer.

Hope that helps. Let me know if you’re still having problems.

1 Like

@robmc I see Rob, I wanted to be able to use the keys from the perform window, I guess that’s not possible, so I guess I instead need to create my own key triggers separately

The camera component should work fine in your perform window. You just need to make sure the ‘Panel COMP’ parameter of the camera is pointed to the same operator that will be your perform window (the ‘project1’ container in the default file), so that it gets the correct mouse and keyboard messages. And then when the perform window is open, make sure you’ve clicked inside the window so that it has keyboard focus (clicking the top windows bar isn’t enough).

Let me know if you’re still having problems with it.

1 Like

@robmc thats a great tip Rob thank you, the other thing that I need help with is that the default speed of the camera movement for the keys is sooooooooooooo slow; as you know there are parameters to change that speed; I change them and they seem to have no effect, any tips? i want the movement to happen way faster when using those keys

Inside the camera comp, in the CameraExt DAT on line 395/396 you can see where the keyboard movement speeds are calculated. Basically it’s just seconds * the speed multiplier parameter.

So, by default the camera is moving around 3 units/second which works fairly well with the 1x1x1 cube in the default scene. However, if your scene has geometry that is 100s or 1000s of units in size you might need to increase that speed significantly. For example, when I set the speed to 100, a light tap on the keys will send the default cube out of frame.

1 Like

@robmc very interesting, will try and report back :slight_smile:

Hi @robmc I was able to setup this WASD cameraViewport walktrough camera in perform mode. Thanks

There is one little behaviour that I would like to change: I would like to walk with WASD and at the same time rotate the camera with the mouse, like actually playin a first person game. Is there an easy way to do it, maybe built into the cameraViewport? Or some other setting, that allows 2 inputs at the same time?
Right now the walk / position movement stops when I click and rotate the mouse.
Or actually, maybe the peform windows needs full focus, so the mouse rotates the camera all the time, without clicking…

Thanks for the suggestion. It’s not immediately possible with the cameraVewport, but it is something we could potentially add in the future.

If you want to experiment yourself in the meantime, there’s a function call in the camera extension called ‘look’ that handles that first person rotation that I think you’re looking for. It takes two arguments (u, v) that control how much it pivots up or down.

You could add a public function to the extension like:

def Look(self, u, v):
self.cameraInst.look(u.v)
self.fillMath()

If you then call that function whenever the insideu or insidev values change on your panel and give it the relative movement that might get what you’re looking for.

Hope that helps. Let me know if you have questions.

Hi @robmc for some reason my WASD keys aren’t working :frowning:

I’ve tried using the perform window, as well as a split pane displaying the panel. All of the other keyboard inputs work seamlessly (h for home, t for top etc.) and I’m also able to control it with mouse input.
I have turned on WASD keys toggle and tried to toggle Allow UI shortcut keys on my project container (my panel comp reference).

No idea why this doesn’t work as intended. Working on most recent version 2023.11600 and Apple Silicon.

I’ve also noticed that when using a Null Comp as a Lookat for my Camera Viewport, it doesn’t pick up on the rotation parameter on my Null (same applies for Scale and Pivot parameter, Translate works).
It might seem counter intuitive to use Camera Viewport AND have a Lookat Null to automatically rotate around my object (via absTime) but perhaps still doable. I can use a Circle SOP and use that as Path but I figured you might have a solution while were at it.
Cheers

Sorry you’re having problems. The WASD keys all appear to be working when i try it, but I’m on windows so there could be something different on Mac.

I gather from your post that you have the panel comp parameter pointing to a different panel rather than the one included in the cameraViewport? If so, do the WASD keys work in a default version of the cameraViewport with nothing else changed?

If you go into the cameraViewport component, do you see the WASD keys appearing in the keyboardin1 dat log?

As far as using the Lookat parameter, I’m honestly not too sure how that would work in the cameraViewport. That component wasn’t really designed to work alongside some of the built in options on the camera. Have you tried using the Object navigation mode? That will place the pivot at the center of the geometry so that the camera always rotates around it. There is also the Auto-rotate parameter that lets you keep the camera spinning that might be useful.