SOLVED: Help with if player at and if player collides with object.. script.

Started by barefoot, Sat 30/04/2011 13:15:01

Previous topic - Next topic

barefoot

Hi

I have now sorted this out and everything works as it should..


Aghhhhhhhh I need a very gentle hand with this code for it to work properly... Will you please help.....

In rep exec:

Code: ags
if (cwizard.x >150 && cwizard.y > 137)&& (cwizard.IsCollidingWithObject(object[7] == 1))
} 

  cwizard.Say("Ouch!!");
  GiveScore (-1);
   SetGlobalInt (1, 100);


Or could have if an object is visible and player at given location.

All help appreciated

barefoot





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

Matti

The brackets are totally wrong, it should look like this:

Code: ags

if (cwizard.x > 150 && cwizard.y > 137 && cwizard.IsCollidingWithObject(object[7] == 1))
{ 
  cwizard.Say("Ouch!!");
  GiveScore (-1);
  SetGlobalInt (1, 100);
}

barefoot

Hi

cheers Matti

but i'm getting:


Failed to save room room30.crm; details below
room30.asc(126): Error (line 126): Type mismatch: cannot convert 'Object*' to 'int'


barefoot

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

Khris

Code: ags
if (cwizard.x > 150 && cwizard.y > 137 && cwizard.IsCollidingWithObject(object[7]))


Edit: Not to be rude or anything but seriously, it's time you learned how to fix trivial stuff like that.

barefoot

Hi Khris


UPDATE: Have found a suitable solution to this problem

---------------------------------------------------------------------
I did have it but it messed up and went pear shaped...

a button sets off an object visible and animates should a player be cwizard.x > 150 && cwizard.y > 117

this works fine with an else of "He is out of shot" with object not visible. This also works..

In the room rep exec i set up if char collide with object:

Code: ags
 

 {
  if (cwizard.IsCollidingWithObject(object[7]))
  cwizard.Say("Aghhhhhhhhhhhhhhhhhh!!");
  GiveScore (-1);
   SetGlobalInt (1, 100);
  
	}


Unfortunately this fails to happen..

barefoot

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

Matti

Sorry, but what the hell are you doing? You are putting the "{" before the if-condition which doesn't make any sense at all. So "this fails to happen" means that you're getting an error, right?

It should look like this (as stated above):

Code: ags

if (cwizard.IsCollidingWithObject(object[7]))
{
  cwizard.Say("Aghhhhhhhhhhhhhhhhhh!!");
  GiveScore (-1);
  SetGlobalInt (1, 100);
}


Edit: Okay, seems to be solved. What was the 'suitable solution' ?

barefoot

Hi

that fails to work as well in rep exec....

object 7 exists as it runs ok with animation. for the record will collide still run if object animates and then visible false?

i have other options i am looking at

cheers

barefoot





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

monkey0506

Quote from: barefoot on Sat 30/04/2011 15:31:00for the record will collide still run if object animates and then visible false?

This isn't even English that you're speaking. I'm not trying to be rude, I'm just making a statement of fact. Seeing as I'm pretty sure nobody in these forums speaks the language you're using, you might want to either learn to speak English, or get a better translator. Seriously.

I'm assuming that you're asking whether or not Character.IsCollidingWithObject will ever return true if Object.Animating is true. I don't see why Object.Animate would alter Object.BlockingWidth or Object.BlockingHeight. I haven't actually tested it, but it seems like it would work fine to me.

That's if I've even understood your mangled Engrish properly.

Edit: The bit about "visible false"..I again can only guess at what you mean, but if you mean that you're setting Object.Visible to false and then still expecting it to collide with your character, then you don't have a grasp on how these things work at all. If the object is not visible, then for all intents and purposes it doesn't exist in the room at all. You can't interact with it, you can't collide with it, it's not there until you turn it back on by making it visible again. So if you're turning it off and then expecting it to collide with your character, it's never, ever, ever going to happen. Ever.

barefoot

Hi Monkey

Yes I understand what you are saying.. obviously the object needs to turn on and off... in this case I have turned off much too early.. it was a silly oversight i'm afraid.. Im sure we've all felt stupid at some point...

I know you don't mean to be rude and i'm sure you've come across this once too often as such and it p***** you off... You just need to be more flexible in your approach to reading and answering, seriously.. or just don't answer at all.. which would be a shame as I generally appreciate your solutions as well as others. I have a very low term memory which means i can only hold info for a short while and that's something I have to live with. Not making excuses and I will try even harder.

I have now sorted this out and everything works as it should..

Cheers

Barefoot





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

SMF spam blocked by CleanTalk