Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Sun 12/06/2011 07:47:38

Title: Character collides with object events not working...
Post by: barefoot on Sun 12/06/2011 07:47:38
Hi

I am using a trial game to complete this task and I am having a problem. My character or object may be blocking events for when character collides with the object?

I am having my character jump up the screen via keypress 1 (move using -y  eNoBlock, Anywhere ) to head butt an object that is slowly moving right to left eNoBlock, eAnywhere.
I am having to use Wait(25) before the character then moves (move using +y ) back down the screen. Unfortunately the collision events do not take place when the character collides with the object (dreaded watch!) Think of Sonic the Hedgehog jumping up for Stars...


object[0].Move(-25, 55, -1, eNoBlock, eAnywhere);


Global

{
 if (keycode == eKey1) {  // Key 1

 cEgo.StopMoving();
 cEgo.SetWalkSpeed(10, 10);
 cEgo.Move(cEgo.x + 0, cEgo.y -176, eNoBlock, eAnywhere);
Wait(32);
 cEgo.Move(cEgo.x + 0, cEgo.y +176, eBlock, eAnywhere);
 cEgo.StopMoving();
cEgo.SetWalkSpeed(7, 7);

}
}


I also have in Room


function room_RepExec()
{
 if (cEgo.IsCollidingWithObject(object[0])) {
  object[0].Visible = false;
  Display("10 points.");
  GiveScore(10);

}
}


Is there something i am overlooking or something I should replace/amend?

Grateful for all help

barefoot

Title: Re: Character collides with object events not working...
Post by: barefoot on Sun 12/06/2011 08:20:19
Hi

This works up to the point of making object off and adding points but the character fails to move back down screen:

Global

{
  if (keycode == eKey1){ {  // Key 1
   
  cEgo.StopMoving();
  cEgo.SetWalkSpeed(10, 10);
  cEgo.Move(cEgo.x + 0, cEgo.y -176, eNoBlock, eAnywhere);


}
  if (cEgo.IsCollidingWithObject(object[1])==1 && player.Room==1) {

  cEgo.Move(cEgo.x + 0, cEgo.y +176, eNoBlock, eAnywhere);
object[1].Visible = false;
  Display("10 points.");
  GiveScore(10);
{
if (object[1].Moving) {
  object[1].StopMoving();


Help/hint still appreciated

barefoot

Title: Re: Character collides with object events not working...
Post by: barefoot on Sun 12/06/2011 08:22:05
Hi

At the moment this is now solved.. If you have some options / hints for better scripting they would be welcomed.

barefoot
Title: Re: Character collides with object events not working...
Post by: monkey0506 on Sun 12/06/2011 08:29:27
Well, something that stands out to me in the original code is that you're telling the Character.Move command explicitly not to block other scripts, and then immediately negating that by calling Wait.

So, your room_RepExec would never be run during that movement..seeing as you explicitly prevented it from doing so. Of course if you really needed to you could use repeatedly_execute_always (in the global or the room script), which isn't blocked by blocking commands like Wait.
Title: Re: Character collides with object events not working...
Post by: barefoot on Sun 12/06/2011 09:20:13
Cheers Monkey

Yes, I can see what you mean now...  it is now working as I wanted but more to do before I can finally close this case.

Thanks again Monkey

:=

barefoot