hi
I’ve created a variable
UiStats.attributes.add('spawn', { type: 'entity' , title:'SpawnPoint'});
and printing its position on start
UiStats.prototype.initialize = function() {
console.log(this.spawn.name +" " + this.spawn.position);
};
although I elevated the object to [0,0.5,0] and it’s located under an object that is at [0,0,0]
this.spawn.position generates [0,0,0]
and only this.spawn.localPosition gives the desired [0,0.5,0]
what position stands for? why was it returning empty vector?
will
April 28, 2020, 2:04pm
#2
position
isn’t part of the public API. It’s an internal temporary property. (It should really be named _position
to clearly mark it as internal).
You need to do:
UiStats.prototype.initialize = function() {
var position = this.spawn.getPosition();
console.log(this.spawn.name + " " + position.toString());
};
(See the API reference manual for pc.Entity#getPosition
).
will:
getPosition()
so what you say is - if i don’t wanna use locaposition, i rather use getPosition() than just position?
will
April 28, 2020, 2:29pm
#4
You shouldn’t use either localPosition
or position
properties. They are not part of the API.
You should use:
pc.Entity#getLocalPosition // get position relative (local) to parent
pc.Entity#getPosition // get world-space position