Topic: Problem in script

I got few objects map, and the problem comes when object has parent. If it has parent it seems i only get starting position or rotation (getposition etc), but the collision test of the object works fine... And if i try getting another object position it works (if has no parents)..

is this bug? And is there some way to get the position object which has parent?

Re: Problem in script

you can use : getTransformedPosition and getTransformedRotation
they return the world coordinates according to the matrix of the object

full list here : http://wiki.maratis3d.org/index.php?tit … tions_list

one thing to keep in mind, matrices are only updated frame by frame, or you need to call "updateMatrix" to force it
(in case you move an object and wants to get it's global position immediately after).

Re: Problem in script

That solved the problem smile thanks big_smile and thanks for the updateMatrix tip too big_smile will come useful smile

i was looking that list of functions but somehow my eye did not catch those functions :-/ . (all tho im not suprised, i cant even see if my colleague is walking past me big_smile )

Re: Problem in script

Hm did not want to make new threat so..
is there function to delete object in LUA script..
I see deactivate but is there delete? big_smile thanks for help in advance big_smile

Re: Problem in script

Hi, there is no delete as it can be a bit unsafe to deal with memory from lua (as getObject handle pointers),
deactivate will totally disable the object.

If your initial need is to clone / delete lot of objects, try to see it as a buffer to reuse the same objects a maximum.
Even getClone should on maximum be used out of the update loop (for better performance).

Re: Problem in script

anael wrote:

Hi, there is no delete as it can be a bit unsafe to deal with memory from lua (as getObject handle pointers),
deactivate will totally disable the object.

If your initial need is to clone / delete lot of objects, try to see it as a buffer to reuse the same objects a maximum.
Even getClone should on maximum be used out of the update loop (for better performance).

Reason why I asked is that im doing FPS game, where i will make bullets (clone bullets) and if they are near object i would like to delete them.
But i think the bullets will go so fast that there would not be too much of them..so i can disable them and then use them again.
Is there delete in c++? big_smile

well last night i tried coding and tested and made (cloned) about 2000 objects big_smile and it still went smoothly..(very simple object)
(but also the all cloned ones rotated same time O.o cos did not have script done complete yet)
Thanks for tips smile will help me out big_smile

EDIT:
Further questions: when i clone the object will get the position of reference object?
also the clone object will have same parent ( or then i got some error in my code big_smile ) , so how i can just remove the parent of the object? tongue

Last edited by pleedian (2013-04-19 10:23:27)

Re: Problem in script

Hi,
in c++ you can delete yes, there is no restrictions as you get everything as-it.

- clone will get the position and parenting of reference object yes, it's an exact clone except for the name.
- you can modify the parenting in lua using "setParent" : http://wiki.maratis3d.org/index.php?title=SetParent

Re: Problem in script

Thanks alot smile again big_smile

Ok, i did try that setParent, but apparently if I set parent in editor, it does not work (setParent to none)?  (not problem for me tho tongue )
So for more info what i tried and did:
-I had a gun where it shoots bullets, bullet had gun as parent (set on editor) so it rotates..and then i cloned bullet..but setParent did not work..
-I then just added box in the gun where the bullet start (bullet had no parent) and then cloned the bullet. (alltho now that im writing, why not just use the gun as starting point >.< .....)

oh and just quick question, ( i did went for that wiki list of functions thru, did not see any function for this) but is there a way to draw a line in lua scripts?
I would like to draw line from a to b..
Or how to do it in lua script other ways of doing it, if there is not?