Page 1 of 1

Automatic collision change?

PostPosted: Mon Dec 14, 2009 6:49 pm
by Sonic
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.

Re: Automatic collision change?

PostPosted: Mon Dec 14, 2009 7:49 pm
by standardtoaster
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} : {}}}}}}}

Re: Automatic collision change?

PostPosted: Mon Dec 14, 2009 8:55 pm
by Kilinich
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)}.

Re: Automatic collision change?

PostPosted: Thu Dec 17, 2009 6:45 pm
by Sonic
Thanks Toaster! Your script worked! Killinch, i'm sorry to say, yours didn't.

Re: Automatic collision change?

PostPosted: Thu Dec 17, 2009 6:47 pm
by standardtoaster
Actually both scripts work. Mine is a bit longer but easier to understand. Kilinich's is a bit shorter but harder to understand.

Re: Automatic collision change?

PostPosted: Thu Dec 17, 2009 6:50 pm
by Sonic
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.

Re: Automatic collision change?

PostPosted: Thu Dec 17, 2009 9:35 pm
by KarateBrot
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.

Re: Automatic collision change?

PostPosted: Fri Dec 18, 2009 8:52 am
by Kilinich
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.

Re: Automatic collision change?

PostPosted: Fri Dec 18, 2009 5:39 pm
by KarateBrot
i already encountered a not-working-bug in phun with math.mod

Re: Automatic collision change?

PostPosted: Fri Dec 18, 2009 6:26 pm
by Kilinich
KarateBrot wrote:i already encountered a not-working-bug in phun with math.mod

Can you give an example?

Re: Automatic collision change?

PostPosted: Sat Dec 19, 2009 2:44 pm
by KarateBrot
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.