1 registered members (TipmyPip),
18,618
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Physic Entity - How to differentiate hitting wall or floor?
[Re: Coisox]
#241682
12/18/08 04:06
12/18/08 04:06
|
Joined: Dec 2008
Posts: 3
C64
Guest
|
Guest
Joined: Dec 2008
Posts: 3
|
I have a similar question. I'd like to determine if the collision occured with block type 1 or block type 2. I set different flag values for the blocks, but don't know how to access them in the collision event. I was hoping to do something like the following.
function ContactEvent()
{
switch (event_type)
{
case EVENT_BLOCK:
{
if (is(CollidedBlock,FLAG6))
snd_play(sndA,100,0);
else
if (is(CollidedBlock,FLAG5))
snd_play(sndB,100,0);
}
}
}
So the big question is: Is there a way to identify the CollidedBlock and then determine its flag settings? Thanks in Advance...
Last edited by C64; 12/18/08 04:09.
No more Programming Languages please, my head is a filled up!
|
|
|
Re: Physic Entity - How to differentiate hitting wall or floor?
[Re: C64]
#241683
12/18/08 04:19
12/18/08 04:19
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Coisox, C64 has answered if for you with his question. Thats basically how I would do it. See his code chunkk and my reply to him below for how to make it work. VIC20  C64 your answer is if(is(you,FLAG6)) A collision is two objects colliding, one is "me" the other is "you". In the case of EVENT_BLOCK, "you" is going to be the block that 'me' ran into...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Physic Entity - How to differentiate hitting wall or floor?
[Re: EvilSOB]
#241684
12/18/08 04:37
12/18/08 04:37
|
Joined: Dec 2008
Posts: 3
C64
Guest
|
Guest
Joined: Dec 2008
Posts: 3
|
Thanks SOB, I had already tried that. It seems to me in my tests that you does not reflect the collided block. I tried a statement like:
case EVENT_BLOCK:
{
if (you)
snd_play(sndA,100,0);
}
This didn't work, so you must be zero. To verify this I set one of my debug panel values to you (reported back 0). I know that the event block does get triggered, because when I rem the "if" line the sound will play. PS. Almost registered myself as TimexSinclair!
No more Programming Languages please, my head is a filled up!
|
|
|
Re: Physic Entity - How to differentiate hitting wall or floor?
[Re: C64]
#241689
12/18/08 06:23
12/18/08 06:23
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Dammnit, you is ONLY for entities.... I forgot. Try this... case EVENT_BLOCK:
{
if(normal.z>0)
snd_play(sndA,100,0); //play floor-hit sound
else if(normal.z<0)
snd_play(sndB,100,0); //play ceiling-hit sound
else if((normal.x!=0)||(normal.y!=))
snd_play(sndC,100,0); //play anywall-hit sound
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Physic Entity - How to differentiate hitting wall or floor?
[Re: EvilSOB]
#241690
12/18/08 06:36
12/18/08 06:36
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
You can get the texture on a object if you use c_trace with SCAN_TEXTURE.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Physic Entity - How to differentiate hitting wall or floor?
[Re: WretchedSid]
#242260
12/22/08 05:30
12/22/08 05:30
|
Joined: Dec 2008
Posts: 3
C64
Guest
|
Guest
Joined: Dec 2008
Posts: 3
|
Thanks to SOB and Sylar for all the help. I have found a solution that works for me. I will post it here in case it may be of help to others.
function ContactEvent()
{
switch (event_type)
{
case EVENT_BLOCK:
{
c_trace (me.x, target, IGNORE_ME|IGNORE_PASSABLE|IGNORE_MAPS|IGNORE_MODELS|IGNORE_SPRITES|USE_BOX|SCAN_TEXTURE);
if (tex_flag3)
snd_play(sndA,100,0);
else
if (tex_flag4)
snd_play(sndB,100,0);
}
}
}
No more Programming Languages please, my head is a filled up!
|
|
|
|