Using the combination of ‘Player Controller’ and ‘Camera Controller’ community made logic nodes, I have managed to get the camera control in a fly through style. However I’m just struggling with the back and forward movement.
Currently forward and back keys - mapped to ‘w’ and ‘s’ on keyboard are taking me in the z axis - up and down in the terrain model I’ve loaded. how would I get this to be on the flat x,y axis?
Here is my current node setup:
That Controller is actually moving you along the local x and y axis of your camera… the problem is that the local y axis of a camera is pointing upwards and it’s z axis is pointing forward…
So you actually want to move on the cameras z axis with w and s and move on the x axis with a and d.
This is something the Player Controller cannot do since it assumes that you move on the x and y axis.
May I suggest this as an alternative setup for your movement?
(On the inside, the player Controller is actually not that much more than this.)
Genius - thank you so much zaethan, so I now have the below setup adding mouse middle button for look about, which is working well for flying around a terrain model.
However the only thing that seems troubling is that when you press middle mouse and try and rotate to start to look behind you it flips out and resets, as if it can’t cope going further than a 180 degree forward sweep?
Here is the example to test - https://rossoe.itch.io/christchurch-nz-terrain
it’s 46mb so excuse the loading time.
I guess the issue is caused by the first object slot in the camera controller. If an object slot is left empty, armory will use the object that you assigned the tree to.
I guess you assigned the tree to the camera. Thus it behaves as if you assigned the camera to both slots.
Try the following setup:
add an empty into your scene
place it exactly where the camera is
parent the camera to the empty
assign the empty into the first slot of the camera controller
I just noticed that this setup will only move the camera, not the empty… You could add a set location node to always place the empty in the camera’s location. This would probably make it work, but it’s not a nice solution. At the moment, I don’t even know of any specific reason why the camera controller needs two inputs…
I mean, I know why I added it back then, but now I think it could be done with only one object input.
I will have another look at this tomorrow.
So I just created a pull request for a rotate around axis node. Once it gets merged you should be able to do the following:
The first part multiplies the mouse movement with a small (and negative) number to scale it down.
The “rotate left right” section uses the z axis as rotation axis and the x value as angle to make the camera look left and right.
The “rotate up down” section uses the ‘vector from transform’ node to get a vector facing to the “right” of the camera which will be used as the rotation axis for looking up and down. It then uses the y value as angle.
I also added mouse locks so one can move the mouse infinitely without hitting any border (I don’t know whether locking currently works in the browser though)
Fantastic work zaethan, I can’t wait to try that out.
Here is the pull request if anyone else is following - https://github.com/armory3d/armory/pull/1266
I assumed there may be some variation in how mouse is treated in HTML5 export vs packaging the game as it’s own app.
OK so finally tested your new ‘rotate object around axis’ node and it’s working very nicely within Armory Player (Browser & Krom) from within Blender.
However when I try and export to HTML5 and upload to itch.io it just get’s stuck after loading model with no mouse control.
I’ve updated the test model with new controls here - https://rossoe.itch.io/christchurch-nz-terrain
This is a weird error, but I think I was able to fix it (just by moving some code around).
PR is here https://github.com/armory3d/armory/pull/1271
I say “I think” because I am still confused that this only happens on exported builds…
Fantastic - this now works beautifully.
I’ve added back in Z axis ‘height’ control with R and F keys for complete control of movement as per below:
Thanks so much for your work on this.