ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperCube > Help with CopperCube
freeze y?
Author Text

Registered User
2019-09-11 22:39:58

I have an awesome lookToObject behavior script, but the only thing it does wrong is, when I get close to a plane, it makes it tilt back. I'd love it to stand straight even if I get close. I know I can use a billboard, but billboards don't work with shadows.

Bear in mind that when you create a plane, coppercube creates it laying down instead of standing. Poor CopperCube :D - so to be upright and facing north, I had to rotate it like so: 0.0, 0.0, 90.0

see pic!

here is the source code:

/* <action jsname="action_LookToObject" description="Look in direction of target object 3D">
<property name="targetNode" type="scenenode" />

action_LookToObject = function()

action_LookToObject.prototype.execute = function(currentNode)
var position_target = ccbGetSceneNodeProperty(this.targetNode, "Position");
var position = ccbGetSceneNodeProperty(currentNode, "Position");
var rotation = ccbGetSceneNodeProperty(currentNode, "Rotation");

var dist=Math.sqrt( Math.pow( (position.x-position_target.x) ,2) + Math.pow( (position.y-position_target.y) ,2) + Math.pow( (position.z-position_target.z) ,2) );
var pi=Math.PI;
var look_angle_horz=( (Math.atan2(pos_o_x,pos_o_z) )*180/pi )-180;

var look_angle_vert=( (Math.atan2(pos_o_y,dist) )*180/pi );


Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Internat?onal" (you are not logged in)




Forum Codes

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



Software: Ambiera Light Forum. © 2008-2019 Nikolaus Gebhardt, Ambiera e.U.