Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Physic Entity - How to differentiate hitting wall or floor? #215741
07/13/08 08:22
07/13/08 08:22
Joined: Jun 2008
Posts: 91
C
Coisox Offline OP
Junior Member
Coisox  Offline OP
Junior Member
C

Joined: Jun 2008
Posts: 91
Both walls and floor come from the same .wmb file. For physic entities, how can I determine whether they hit the wall or floor so that I can play different sound for each type of hit?

In the event function, both floor and wall is considered as EVENT_BLOCK. If I don’t want to create dummy walls (as entity) for this detection, is it possible?

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
C
C64 Offline
Guest
C64  Offline
Guest
C

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.

Code:
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! wink
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 Offline
Expert
EvilSOB  Offline
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 laugh 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
C
C64 Offline
Guest
C64  Offline
Guest
C

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:

Code:
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! wink
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 Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Dammnit, you is ONLY for entities.... I forgot.

Try this...
Code:
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 Offline
Expert
WretchedSid  Offline
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
C
C64 Offline
Guest
C64  Offline
Guest
C

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.

Code:
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! wink

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1