The Daily Click ::. Forums ::. Klik Coding Help ::. parent and child
 

Post Reply  Post Oekaki 
 

Posted By Message

MasterM



Registered
  02/01/2002
Points
  701

I am an April Fool
23rd February, 2011 at 22:57:14 -

here is something thats super easy to code (i think) and i am probably just too stupid:
i want to have an object (bullet) with a dummy object attached to it
....................

so i create a bullet object every X amount of time (well I have an active thats my counter and I add +1 to it ALWAYS / IF 30 set Value A to 0 and it keeps on counting again)

so every Value A = 30 of counter active object I:
+ create my BULLET object
+ create my dummy object
and I set the position of dummy object to be ALWAYS 0,0 of BULLET object

note: i have more bullet objects (the same objects) on screen at run time

and for some reason that silly code doesnt really work. do i miss something? should it actually LOGICALLY work or is my thinking just wrong?

my idea
think of a bullet like you find it in Mario Image now the player has to hit it's "HEAD" in order to destroy it - that's where I would place it.

if the player just hits the "body" and not the "head" / the dummy object / collision box he would lose a life.

get what i mean?

thanks a lot

 
Image

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd February, 2011 at 23:31:40 -

Your code should work fine, but you need a few more lines to handle collisions.
If it doesn't work, it probably means you don't have the same number of bullets and detectors.

+ Always
-> Position Detector at 0,0 from Bullet

+ Detector collides with *something*
-> Detector: Subtract 1 from HPs (make sure "HPs" has a default value > 0)

+ Always
-> Bullet: Set HPs to HPs("Detector")

+ HPs of Detector = 0
-> Detector: Destroy

+ HPs of Bullet = 0
-> Bullet: Destroy


You might want to consider using embedded collision detector instead - it makes stuff like this really easy.

 
n/a

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
25th February, 2011 at 20:27:37 -

Are you sure that your dummy object understands this rule:
and I set the position of dummy object to be ALWAYS 0,0 of BULLET object

My interpretation skills of clickteam products like mmf and tgf are a bit rusty. But if there are multiple bullets in the area, will every child be set to the position of his parent? Or will all children be put on one and the same bullet? I've no idea, it might all go well like Sketchy says.

But you can try to avoid this by shooting a bullet which has a certain movement and that movement can be used (perhaps with a little coordinates offset) for it's parts. Example: a bullet that goes in a straight line, if the bullet consists of a head, body and propulsion system, all of those can have the same movement for the same straight line. And that works with all sorts of movements, like homing movements too.

 
Image jenswa.neocities.org
   

Post Reply



 



Advertisement

Worth A Click