Need help with character collisions

This is a public forum, where you can find out everything you wanted to know about making games. Please don't use this forum as a place to recruit new members.

Moderators: adeyke, VampD3, eriqchang, Angelus3K

Post Reply
Message
Author
dungeonsofdorks
Royal Servant Status
Posts: 116
Joined: Tue May 04, 2004 3:07 pm
Contact:

Need help with character collisions

#1 Post by dungeonsofdorks » Wed Feb 06, 2008 1:02 am

I'm trying to make it so that when a character touches the main character, it kills you. It's successful, I've used the IsCollidingWithChar function and like I say, everything works. It's just that he isn't close by. I imagine it has to do with transparencies. Is there any way around this? I don't want to shrink the ego's transparency, as I use it to maintain sideways animation and the like. Blah blah.

Also, I'm using the FollowCharacter function to have the thing chase my little ego man, but sometimes it goes around him and then comes back. Can that be fixed, either? I hope this makes sense. Thanks in advance.

- Tom

pass
Royal Servant Status
Posts: 129
Joined: Wed Mar 22, 2006 8:38 pm
Location: Israel

#2 Post by pass » Wed Feb 06, 2008 7:35 am

What do you mean he isn't close by? Does the function trigger too early, when they aren't touching yet?

With FollowCharacter, are there any unpassable areas between the follower (I'm assuming a ghost?) and ego?

dungeonsofdorks
Royal Servant Status
Posts: 116
Joined: Tue May 04, 2004 3:07 pm
Contact:

#3 Post by dungeonsofdorks » Wed Feb 06, 2008 9:51 am

The function triggers when they aren't actually touching, though transparency edges may be touching. That's my problem. I need a way around that. There are no objects between them.

Erpy
Forum Administrator
Posts: 11434
Joined: Tue Sep 25, 2001 8:28 pm
Location: The Netherlands

#4 Post by Erpy » Wed Feb 06, 2008 11:21 am

Have you tried using the AreThingsOverlapping-function instead. It's accuracy is a lot more fine-tunable.

Image

dungeonsofdorks
Royal Servant Status
Posts: 116
Joined: Tue May 04, 2004 3:07 pm
Contact:

#5 Post by dungeonsofdorks » Thu Feb 07, 2008 12:02 am

Ok. I can't figure out how to fine tune it. I can do

Code: Select all

if (AreThingsOverlapping(cEgo, cTut)) {
//do stuff here
}
but I need to make it so if cTut is overlapping cEgo by 21 pixels, something happens. How do I do that?

OK. Problem. Here.

Code: Select all

  // script for Room: Repeatedly execute
if (GetGraphicalVariable("virustouch")==1)
if (cEgo.IsCollidingWithChar(cTut)==1) {
//Death animation goes here
cEgo.ChangeRoom(4);
PlayMusic(5);
gIconbar.Visible = (false);
lblDeath.Text = ("Feeling a bit under the weather?");
gDeath.Visible=(true);
gDeath.SetPosition(160, 0);
}  
 
works. but if I change it to

Code: Select all

  // script for Room: Repeatedly execute
if (GetGraphicalVariable("virustouch")==1)
if (AreThingsOverlapping(cTut, cEgo)) {
//Death animation goes here
cEgo.ChangeRoom(4);
PlayMusic(5);
gIconbar.Visible = (false);
lblDeath.Text = ("Feeling a bit under the weather?");
gDeath.Visible=(true);
gDeath.SetPosition(160, 0);
}  
It doesn't work anymore. Returns: Error LINE 55 (which is the GetGraphicalVariable?!?!) Type mismatch: Cannot convert 'character*' to 'int'

WHY WHAT ARRRRRRR

Erpy
Forum Administrator
Posts: 11434
Joined: Tue Sep 25, 2001 8:28 pm
Location: The Netherlands

#6 Post by Erpy » Thu Feb 07, 2008 1:16 am

Try this:

Code: Select all

  // script for Room: Repeatedly execute 
if (GetGraphicalVariable("virustouch")==1) 
if (AreThingsOverlapping(TUT, EGO)>21) { 
//Death animation goes here 
cEgo.ChangeRoom(4); 
PlayMusic(5); 
gIconbar.Visible = (false); 
lblDeath.Text = ("Feeling a bit under the weather?"); 
gDeath.Visible=(true); 
gDeath.SetPosition(160, 0); 
}   
First of all, in order to specify how large the overlapping area is allowed to be, you must put a value after the parentheses. Secondly, the function doesn't seem to use the object-oriented approach most other functions use. So you must either fill in the character ID's in there or the number of the characters.

Image

dungeonsofdorks
Royal Servant Status
Posts: 116
Joined: Tue May 04, 2004 3:07 pm
Contact:

#7 Post by dungeonsofdorks » Thu Feb 07, 2008 1:35 am

THANK YOU. That makes sense. It works perfectly now. Thanks so much, Erpy. You're awesome.

Post Reply