Heyy guys facing one issue about assigning entity to array element… please help.
This peace of code is working:
But this is NOT
this.road_unit is ‘Entity’ which I’m assigning from editor window.
this.road_units are array element:
And here is error i’m getting in browser:
Please Help, Many thanks in Advance
January 25, 2018, 10:40am
Why not use
It should work too.
Thanks for your reply…
But again same, this is also not working… and same error is there
January 28, 2018, 2:37pm
Could you share your project link or create a minimal demo for your issue ?
January 29, 2018, 4:39am
posZ = this.road_units[this.road_units.length - 2].getPosition().z - 8;
Change 2 to 1. Because when
this.road_units.length equals 1, the index will be -1, that’s out of range.
Ohh… i forgot to change that… was just experimenting some other logic…
Can you please check the line no 42 once:
I’m trying to do spawn pickups again on the road_unit once its position gets reset to back… Actually this is an actual issue for which i’m looking for. (i.e pickups not re-spawning after road_unit gets reset its position.)
January 29, 2018, 5:20am
I don’t know your game logic.
spawnPickUps, you pass
unit and add children for it. The result is
unit.children will become larger and larger. Why you do this, it seems useless…
In SpawPickup function i’m passing the one road_unit and this function will consider the road_unit as parent and add pick up objects as a child…
As you can see here, the same is working (when initially I’m adding pickups on road_unit) line no 68:
I’m also wondering why the same function works at one place but not at other
So my thought on this was: we can not assign ‘Entity’ to the Array element in java-script (or in PlayCanvas).
By this i wrote heading: How to assign ‘Entity’ to array element ?
Anyways is there any other workaround can you suggest me here ?
Thanks a lot for your time