Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Rotatable third person camera - lost...

j9907
Registered User
Quote
2019-05-23 00:47:08

var player = ccbGetSceneNodeFromName("Player");
var cam = ccbGetSceneNodeFromName ("Camera");
var playerpos = ccbGetSceneNodeProperty (player, "Position");

ccbSetSceneNodeProperty (cam, playerpos);


This is what I did. It doesn't work, to put it simply :)... I need a rotatable third person camera for my project. I just can't seem to figure it out...

btw this code is to make it update it's position when the character moves.


Ishmaru
Guest
Quote
2019-05-23 14:41:42

First off ccbSetSceneNodeProperty needs 3 arguments:

ccbSetSceneNodeProperty(sceneNode, propertyName, value)

So the code above should be this:

var player = ccbGetSceneNodeFromName("Player");
var cam = ccbGetSceneNodeFromName ("Camera");
var playerpos = ccbGetSceneNodeProperty (player, "Position");

ccbSetSceneNodeProperty (cam, "Position", playerpos);


All this will do is set the camera to be inside the player. What you may be able to do another node lets call it "Placeholder" and set it as a child of Player, and position it where you would like the camera to be. Now change the code to this:


var placeholder = ccbGetSceneNodeFromName("Placeholder");
var cam = ccbGetSceneNodeFromName ("Camera");
var pos = ccbGetSceneNodeProperty (placeholder, "PositionAbs");

ccbSetSceneNodeProperty (cam, "Position", pos);


Then all you need to do is point the camera's target to the player every frame. I recommend doing all this in a behavior in the onAnimate event.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Interna?ional" (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