## Automatic collision change?

### Automatic collision change?

I was trying to make a car, that when it hits an object, it changes to the next collison group, then the next, then the next. So it would be like

>Collide with A
>Change to B
>Collide with B
>Switch to C
>Collide with E
>Switch to D
>Collide with E again
>Switch to E
>Collide with E yet again
>Switch to F
Etc etc.
I do stuff and break things. You know how it is.

Sonic

Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

### Re: Automatic collision change?

Code: Select all
`e.this.collideSet == 1 ? {e.this.collideSet = 2} : {e.this.collideSet == 2 ? {e.this.collideSet = 4} : {e.this.collideSet == 4 ? {e.this.collideSet = 8} : {e.this.collideSet == 8 ? {e.this.collideSet = 16} : {e.this.collideSet == 16 ? {e.this.collideSet = 32} : {e.this.collideSet == 32 ? {e.this.collideSet = 64} : {e.this.collideSet == 64 ? {e.this.collideSet = 1} : {}}}}}}}`

standardtoaster

Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

### Re: Automatic collision change?

Sonic wrote:I was trying to make a car, that when it hits an object, it changes to the next collison group, then the next, then the next. So it would be like

>Collide with A
>Change to B
>Collide with B
>Switch to C
>Collide with E
>Switch to D
>Collide with E again
>Switch to E
>Collide with E yet again
>Switch to F
Etc etc.

{collideSet = math.mod(2*collideSet, 127)}.
Dream of Algodoo as game development engine...

Kilinich
[Best bug reporter 2010]

Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

### Re: Automatic collision change?

Thanks Toaster! Your script worked! Killinch, i'm sorry to say, yours didn't.
I do stuff and break things. You know how it is.

Sonic

Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

### Re: Automatic collision change?

Actually both scripts work. Mine is a bit longer but easier to understand. Kilinich's is a bit shorter but harder to understand.

standardtoaster

Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

### Re: Automatic collision change?

Really? I tested his and it did absoutely nothing...
Whatever. Anyway, the point is, it works. I've been trying to get it to work since Beta 5 came out.
I do stuff and break things. You know how it is.

Sonic

Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

### Re: Automatic collision change?

Yeah Kilinich's works, too. But you did it in Phun, didn't you? If so it doesn't work because there is a bug with math.mod in Phun.

KarateBrot

Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

### Re: Automatic collision change?

KarateBrot wrote:Yeah Kilinich's works, too. But you did it in Phun, didn't you? If so it doesn't work because there is a bug with math.mod in Phun.

There is no problem with math mod in phun.
And this function works fine because it just do bit shift.
Dream of Algodoo as game development engine...

Kilinich
[Best bug reporter 2010]

Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

### Re: Automatic collision change?

i already encountered a not-working-bug in phun with math.mod

KarateBrot

Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

### Re: Automatic collision change?

KarateBrot wrote:i already encountered a not-working-bug in phun with math.mod

Can you give an example?

Kilinich
[Best bug reporter 2010]

Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

### Re: Automatic collision change?

no sorry i can't. it was a long time ago when it happened.

but i can give an example that doesn't really fit to this topic:
if you open algodoo scenes in phun math.mod is not working. it happened when i was trying to open one of my scenes in phun to make it completely compatible. it was about 3 months ago.
the bug in phun we're really talking about happened before algodoo came out. but maybe something was screwed up, i don't know.

KarateBrot

Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany