ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Help with CopperCube
forum topic indicator How to correctly change Camera position when returning to a previous scene?
person icon
astral
Registered User
Quote
2026-02-24 06:30:59

Hi everyone,

I am working on a project with multiple scenes and I'm having some trouble with the player's position when moving back and forth between them.

The setup:
I have a Gate (trigger) in Scene A that leads to Scene B using the "Switch to another scene" action. In Scene B, I have another Gate to go back to Scene A.

The problem:
When I return to Scene A, the Camera is not at the initial starting point, but it seems to "remember" the last position it had before leaving the scene (which is exactly inside the exit trigger). This creates a loop or leaves the player stuck in the doorway.

What I need help with:
What is the best way to "teleport" the Camera to a specific spawn point only when returning from a specific scene?

I've heard about using a global variable (like ComingFromScene2 = 1) and checking it "When a scene is started" to move the camera node. Is this the most efficient method, or is there a way to completely reset a scene's state when re-entering it?

Please explain me step by step what to do

Thanks in advance for any advice!

person icon
okeoke
Registered User
Quote
2026-02-24 11:40:00

I believe, the simplest way would be to do it with a short script.
// switch to another scene
// put your exact scene name here
ccbSwitchToScene('YOUR_SCENE_NAME_HERE');

// from now on script is actually executed on a new scene
// find player node on a new active scene
var player = ccbGetSceneNodeFromName('YOUR_PLAYER_NODE_NAME_HERE')
// set player position and coordinate
// change to the real coordinate
ccbSetSceneNodeProperty(player, 'Position', 20, 15, 10);
ccbSetSceneNodeProperty(player, 'Target', 20, 15, 15);

You can put those with different parameters right into "Execute javascript" block, or can create a custom action, expose the parameters and reuse it across the game.
Basically, you just use this script in place of "Switch to Scene" action.

person icon
astral
Registered User
Quote
2026-02-24 14:20:49

Thak you, it worked!


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






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