Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
XYZ co-ordinates in front

Newby
Guest
Quote
2019-09-11 01:56:08

Hi,

Was wondering how to calculate just the distance in front of the player position only (not to the side) based on the X & Z target co-ordinates & perhaps position also.

I notice how both X & Z change when I move the mouse up and down depending on the direction of the player - for the target co-ordinates.

This is my code so far but it puts items in front but also to the side - not always only in front:

var posn = ccbGetSceneNodeProperty(player, "Position");
var targ = ccbGetSceneNodeProperty(player, "Target");

var distX = ((targ.x - posn.x) * 0.04);
var distY = (targ.y - posn.y);
var distZ = ((targ.z - posn.z) * 0.04);

ccbSetSceneNodeProperty(clone, "Position", posn.x+distX, posn.y+distY, posn.z+distZ);


Create reply:


Posted by: (you are not logged in)


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