YolkfolkThe Dizzy Fansite 0 logged in0 playing
Community discussion

Collision

Started by A Cool Guy on 5 August 2010 • 3,642 views

7 posts
#54773

Ok i want to make a message appear when the player touches a invisible object i sort of got it working with this code

idx = ObjFind(34);
if(PlayerTouchObject( idx ))
{
    Message0(5,4,"Message goes here");
	MessagePop();
	return 1;
}

however as soon as i touch the object in question the message appears but the game freezes and i cant do anything at all i tried taking out the return and changing it to 0 but nothing works any ideas please. 

👍 0
#71255
[quote data-userid="346" data-postid="54773"]

Ok i want to make a message appear when the player touches a invisible object i sort of got it working with this code

idx = ObjFind(34);
if(PlayerTouchObject( idx ))
{
    Message0(5,4,"Message goes here");
	MessagePop();
	return 1;
}

however as soon as i touch the object in question the message appears but the game freezes and i cant do anything at all i tried taking out the return and changing it to 0 but nothing works any ideas please. 

[/quote]

ermmm you're kinda going about that the wrong way. Use CollideObject_*_*() instead:

func CollideObject_2000_1() { Message2(2,2,""HULLO THEREnYOUNG DIZZY""); Message1(5,9,""OH HELLO GRAND DIZZY""); MessagePop(); }

but you need to set the collide property for the object in the map to 'call handler'

👍 0
#71256
Ahh but what if its in a update room function then how do i use it?
👍 0
#71257
uhhhhh.... you can't call messages from an update room function...

this is why:

the update room function runs about 37 times *every second*, so anything that requires player input is not going to work, because by the time the player has responded, it's already called that bit of code again about 30+ times. Hence the game freezing when you tried it.

You can't have anything *at all* that pauses the code (such as WaitFrames) in an update_room function, or any similar function that is called all the time.



I don't actually understand why you'd have a collide function inside an update room function? surely if you want it to do something on collision, you'd want it to do it anytime you collided with it? if not, just set the collide property to 0 when you don't want to be able to collide with it

CollideObject_*_*() would do that fine, without the need for an updateroom function to do it.
👍 0
#71258
Thanks :smile:
Oh whats the meaning of 2000_1 i assume 2000 is the object number but whats the 1 for?
👍 0
#71259
[quote data-userid="346" data-postid="71258"]

Thanks :smile:
Oh whats the meaning of 2000_1 i assume 2000 is the object number but whats the 1 for?

[/quote]

the 1 is the collision type.

imagine you have a huge tile for colliding with.

0 is exiting from colliding with it
1 is entering colliding with it
2 is continuing to collide with it (e.g. jumping through a flame or hitting a baddie)

use 1 if you only want it to run the code once, use 2 if you want it to run the code all the time while in front of the object, and use 0 if you don't want the code to run until you stop colliding with it.
👍 0