The Daily Click ::. Forums ::. Klik Coding Help ::. Parent and child, destroy the child object
 

Post Reply  Post Oekaki 
 

Posted By Message

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
26th July, 2013 at 26/07/2013 22:22:15 -

Hello, i'm working on an infiltration game and i have a big problem.
I want to make a lamp (Two objects, the lamp (The parent obj) and the light (The child obj)).
I use this code

------------------------------

*Start of frame
=> Create "Light" at "Lamp"

*Always
=> Lamp: Spread value 0 In Value "ID"
=> Light: Spread value 0 In Value "ID"

------------------------------

Screenshot(In editor): http://puu.sh/3MrcV.png
Screenshot(InGame): http://puu.sh/3Mr20.png

------------------------------

The problem is i haven't found any method to destroy the "light" object when i click with my mouse(for example) in the "lamp" object.

I did the spreading method for the ID but i don't have any idea how to use this.

Have you got an idea ? thanks a lot.
Bye !

 
Working on some engines, working for the fun !

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
11th August, 2013 at 11/08/2013 22:44:36 -

What you need to do is something like this

ID of Lamp = ID of Light = Destroy Lamp/Light

This way it marry the 2 up by comparing the ID's. if they are the same then they will both be destoryed. Hope that helps

 
n/a

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
13th August, 2013 at 13/08/2013 15:37:18 -

Hi there, i just found an other way to do it

• When the bullet collides with the lamp
=> Create "LightDestroyer" @ Lamp

• When "LightDestroyer" is overlapping "Light"
=> Destroy Light

It workd because the light is at the same position of the lamp, and light destroyer is 32*32.
So when i create it near a lamp, it collides with the light.

I know this problem can be solved by another way but i tried a lot of things and this is the "old" technique which it works pretty good (Hide the LightDestroyer at start obviously)

 
Working on some engines, working for the fun !

SmartPanda



Registered
  28/07/2013 04:00:49
Points
  2
21st August, 2013 at 21/08/2013 04:15:59 -

Sorry to be invasive, but learn the ID way. It isn't that hard, spread the IDs,and if you need, tell a counter to say you the ID of a object if the Mouse is over it, so you can be sure of the ID each object has.

As a default, make so that each object will have the ALT VALUE A named as "ID".Then you need to work by comparing two IDs, and saying what happens if they aren't equal.

Believe me, I tried to work without using IDs, and I just lost my time, you will really need to understand how to spread values sooner or later.

 
n/a

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
21st August, 2013 at 21/08/2013 13:37:04 -

Hi there smartpanda,thx for your reply.

I did this little MFA and retried it today but i can't get it working.

Can you look at this and tell me what's wrong ?

Thanks

link: https://dl.dropboxusercontent.com/u/47347088/example.mfa


Can i avoid fastloops because i have a lot of them in my game and i have little framedrops already (i'll fix that later if i can ) ?


(Btw, i'm french, sorry for the mistakes )


Edited by Riptide

 
Working on some engines, working for the fun !
   

Post Reply



 



Advertisement

Worth A Click