Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting

2022-04-14 03:53:27

Super strange situation I just dont know why, but when switching camera's from FPS camera to simple camera (to move the mouse) - some parts of my main game Behavior (attached to FPS camera) stop working while other parts continue as normal.

In this situation the "prototype.onKeyEvent" no longer works but other code like every 1000ms continues to work and it seems the "prototype.onMouseEvent" no longer works also in this situation..... super weird....

I have had to create a separate controls input Behavior and not include that code into my main game Behavior and not attach this Behavior to my FPS camera (as before) but to another fixed node instead.

Note its not a matter the main Behavior stopping under the FPS camera when switching cameras as the code was confirmed to continue running when doing this.....

any ideas why ???

2022-04-14 04:21:10

Are you using ccbGetActiveCamera() for the rest of the code other than inputEvents?

I too had some sort of issue when switching the camera from simple to FPS, it happens when you have a simple camera selected as an active camera at the beginning of your scene. and when you change it to FPS camera, it breaks most of the game.
In order to fix this issue. Make your FPS camera as the active camera when the scene starts.
and change it to the simple camera using before first drawing do something behavior.
and it will fix the issue.

I don't know which one is the active camera in your game when the scene starts. but that's the case with one of my project and that's how I fix it.

Hope this is the same case with you too and you will be able to fix it by the same method. As you are using custom code, I can't really say much, if there is something in your code if that's causing the issue.

2022-04-14 06:20:43

Yeah thanks 'just_in_case' - I actually dont use "ccbGetActiveCamera()" in my code anywhere and its not a problem on load as my main FPS camera always loads and runs on start fine anyway.

Its only when I switch from main FPS camera to simple camera for use of the mouse in my game menus and then switch back when finished and ready to continue moving around the world.

I have checked my code and cant see any problems the way I had it before but can confirm its been a very long standing problem of getting any adjustable (user defined) keyboard inputs to work while in the simple camera and menus unless using the fixed default CC "when a key is pressed" behaviors which always work but anyways since I now have a separate Behavior for all keyboard inputs works in every situation....super weird but thats what I had to do...

I have it such that any key can be changed and updated to work in my game from the 'Keyboard' scene including walking and running etc...

2023-04-10 06:03:17

Crazy - almost to the very day 1 year later, I had forgot about this problem above and now have the exact same issue to deal with until I read my own post from a year ago....

Crazy thing is the exact code runs perfectly with zero issues in a more basic Behaviour yet in a more complex one it will run the movement fine until I select the crouch key (code 163) then it breaks everything and all inputs stop working...

Registered User
2023-04-10 07:05:53

There is weird stuff happening when switching the cameras for sure.. dont know why it happens and why its not fixed.. many my projects have been aborted because of this.

2023-04-10 07:32:12

If you create a new Behaviour only with the 'onKeyEvent' code by itself then it works just fine using global variables.

I had to do this exact same thing for my Saturn 7 game to get the inputs to continue even when switching cameras so yeah it related to that definitely.

I just finished my own version of the crouch Behaviour with partial crouching allowed while keeping collisions and just adjusting the gravity settings instead.

I thought I was losing it when the exact same code refused to work right in another Behaviour....anyway its fixed now...

Registered User
2023-04-11 00:36:23

Something worth trying- completely delete the camera and create a brand new one exactly the same (don't just clone it). Usually fixes my problems with switching cameras.

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Internatio?al" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact