Page 1 of 1
Collision problem
Posted:
Wed May 25, 2011 2:55 am
by Clokio
My first project. The collision happen, the sound play, but the collision player is not repealed (script). Can you check my .ged
Thanks.
Re: Collision problem
Posted:
Wed May 25, 2011 4:57 am
by skydereign
The problem is your keydown event is set to repeat. It uses xvelocity=3, so each frame you set xvelocity to 3, even though each frame of collision you set it to the opposite. So each frame it undos the collision event, which is why it doesn't look like it is repeating. It isn't clear how you want to handle slow down in the collisions, but if you are having a keydown event set to repeat, use this code instead of the xvelocity.
- Code: Select all
x+=3;
And remove the keyup event setting xvelocity to 0.
Re: Collision problem
Posted:
Wed May 25, 2011 7:57 pm
by Clokio
Moon defender have the same code and it set to repeat. And when it touch a spike it goes the opposite direction.
How can I use repeat then?
------
I made that new game, the problem it's not the player moving but the object it run into.
Re: Collision problem
Posted:
Thu May 26, 2011 6:58 am
by skydereign
You'll have to be more specific on how you want the wall to repel the player. Also in the collision script, you should be using collide.x-=30, and not x-=30. Do you want slowdown? Instant jumping to the position, and many other factors.
Re: Collision problem
Posted:
Thu May 26, 2011 3:56 pm
by Clokio
It's working.
As I set collision from any direction. Is there a way to know from where the collision is from and maybe a a code to bounce from where ever direction you bump in it.
Thanks
Re: Collision problem
Posted:
Fri May 27, 2011 7:45 am
by savvy
If you want a bounce effect, should you not use PhysicalResponse? set all the values to 1.0 and it will bounce with equal velocity to how It was before. If you want different things to happen depending on the side of the collider the. You need to use top bottom left and right collisions.