Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Save Player Position to Variable?

ygm7
Registered User
Quote
2017-11-21 15:55:01

Is there a way to save the player's position to a variable? Then load it?
So then, I could simply save and load where the player is standing for a simple save game.

Thanks!


tim12345
Guest
Quote
2017-11-21 21:16:35

well... when you save you want to grab the position of the player with javascript interface...

var player=ccbGetSceneNodeFromName("Camera1");
var curPos=ccbGetSceneNodeProperty(player,"Position");

and set your saved variable...

ccbSetCopperCubeVariable("savePosition",curPos);

then use the save variable action...
---> variables and text ---> load or save variable...
select 'save variable'
then type 'savePosition' into the box...

and then… when you want to load the position…
have something trigger this...
---> variables and text ---> load or save variable...
select 'load variable'
then type 'savePosition' into the box..

then get and set your player position to the saved position with javascript interface…

var player=ccbGetSceneNodeFromName("Camera1");
var savePosition =ccbGetCopperCubeVariable("savePosition");
ccbSetSceneNodeProperty(player,"Position", savePosition);

and voila!

p.s. this seems to work on PC but not MAC. I think this could be a bug on Mac.


ygm7
Registered User
Quote
2017-11-22 01:21:06

Ha!
This worked perfectly! Thanks so much!
(This totally should be added into the documentation :D )


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (you are not logged in)


Text:

 

  

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


   






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