ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperCube > Programming and Scripting
XYZ co-ordinates in front
Author Text

2019-09-11 01:56:08


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: "?nternational" (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.