SOLVED: Object collides with Character problem - still a problem

Started by barefoot, Tue 15/06/2010 13:40:59

Previous topic - Next topic

barefoot

Hi

I'm trying to get below script to run as it should..

You get a warning that you need to hurry. Ceiling drops down and squashes you if you run out of time.

If I use eblock then you can't run, if i use eNoBlock then the next piece of script runs.

Am i using the correct IsCollidingWithObject or is it a {} problem?

Code: ags

function room_AfterFadeIn()
{
Display("Clue: You are going to have to hurry!");
SetTimer(1, 320);
object[0].Move(80, 397, 4, eNoBlock, eAnywhere);
if (cindy_bones.IsCollidingWithObject(object[0]) == 1) 

Display("You've been squashed. It's the end of your journey!!");
cindy_bones.ChangeView(17);

}



All help appreciated.


barefoot

I May Not Be Perfect but I Have A Big Heart ..

Gilbert

It won't work because you're checking whether stuff collide in the room Fade_In() event, i.e. it's only being checked once, and it's even just right after the object megins to move.

You need to check this in repeatedly_execute() instead, something like:
Code: ags

function repeatedly_execute(){
  if (IsTimerExpired(1)) {
    if (cindy_bones.IsCollidingWithObject(object[0])) Display("You've been squashed. It's the end of your journey!!"); 
    else Display("Congratulations! You escaped from the trap!");
  }
}

barefoot

#2
Gilbet, thought we had it..

but its not really working.. Ive  set the timer to activate from a region now.

The ceiling drops down as it should with the char behind it but nothing is said (displayed)..I also wanted the char to changeview to 17 if collides...

Code: ags

function region1_WalksOnto()
{
Display("Clue: You are going to have to hurry!");
SetTimer(1, 160);
object[0].Move(80, 469, 2, eNoBlock, eAnywhere);

}


And put this in RepExec:

Code: ags

function room_RepExec(){

    if (IsTimerExpired(1)) {
    if (cindy_bones.IsCollidingWithObject(object[0])) Display("You've been squashed. It's the end of your journey!!"); 
    else Display("Congratulations! You escaped from the trap!");
  }
}


UPDATE

I think it may be a case of distance,speed of object and time..!!

This is what I now use:
Code: ags

function region1_WalksOnto()
{
Display("Clue: You are going to have to hurry!");
SetTimer(1, 120);
object[0].Move(56, 433, 3, eNoBlock, eAnywhere);

}


Code: ags

function room_RepExec(){

if (IsTimerExpired(1)) {
    if (cindy_bones.IsCollidingWithObject(object[0])) Display("You've been squashed. It's the end of your journey!!"); 
    else Display("Congratulations! You escaped from the trap!");
  }
}


Do I really need a Timer?... would it be better to adjust speed of Object with Collision???

barefoot
I May Not Be Perfect but I Have A Big Heart ..

Khris

The use of the timer was just a suggestion, I don't think you'll need it.
The problem is that IsTimerExpired will only return true once, then false again.
Just remove it.

Also keep in mind that Character.IsCollidingWithObject checks the position of the character's feet (the best use would be checking whether the character is standing on a piece of paper they can pick up). For something that's dropping down on the character, I'd check the object's Y coordinate and if the character is standing on a region.

barefoot

Khris

as per my last message, is a timer really needed...

my lastest script works ok..  my only let down is it not able to change cindy_bones view to 17 (squashed view) before displaying "You've been squashed. It's the end of your journey!!"

Thanks for your advice Khris

UPDATE: SORTED

barefoot
I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk