The Daily Click ::. Forums ::. Klik Coding Help ::. Custom Platform Help
 

Post Reply  Post Oekaki 
 

Posted By Message

Greasy



Registered
  15/02/2005
Points
  322
3rd July, 2006 at 20:34:33 -

Right now I have my platform movement just about perfectly the way I want it, but except one thing. Say I have a buttom platform which supports the player. Now you jump, he goes up then gravity kicks in and he comes back down, but sometimes His feet will go a little below the platform, but not all the way through. Right now my events for gravity are: (Dont steal)

Always + Gravity Of < 10 = add 1 to Gravity(player)

Always > "Set Y(Foot Detector) + Gravity(player)"

Always + (Foot Detector)is overlapping a backdrop) > Set Gravity (Player) to 0

Thats basically my gravity. All its doing is if he isnt on a platform it adds 1 to his gravity if the gravity isnt more than 10. I just need it so that his feet dont go into platforms. I know the problem is that its setting his Y position Up too much, but If I lower the gravity strength, he falls really slow.

 
n/a

-Nick-

Possibly Insane

Registered
  24/11/2002
Points
  2468

VIP Member
3rd July, 2006 at 20:56:51 -

Run a fast loop so that the character only moves 1 pixel down per loop.

The number of loops to run is the strength of the gravity. Make sure you put the collision event inside a loop also, or it will active after the loop has occured, similar to what is happening now.


Another little tip: two of the "always" events are useless in your current system.

 
Project: Roller Coaster is on it's way!
http://www.projectrollercoaster.co.uk/
http://www.craftsncreatures.com

JustinC



Registered
  02/04/2006
Points
  1517

GOTM - MAY 2009 - 3RD PLACE!
3rd July, 2006 at 23:26:27 -

I fixed it a different way: I added a second sensor. It is a little below the first "foot sensor". When it is overlapping a backdrop it slows the gravity down (so that he doesn't come down more than 4 pixels at a time). So if he's coming down by say 10 pixels at a time you'd probably want it about 10 pixels down from the first sensor. This way he doesn't come down too slow because it only decreases the gravity when he's close to the ground so it's not noticable. Make sense?

Image Edited by the Author.

 
Image

Greasy



Registered
  15/02/2005
Points
  322
3rd July, 2006 at 23:59:25 -

Indeed, I will try both, and I didn't realize those always events being useless at the time. Thanks!

EDIT : It works a little better, sometimes he doesn't go through. Here is what I have:

Always > Start Loop "grav" 10 times
Player is not overlapping a backdrop > Set Gravity(Player) to 1
On Loop "grav" > Set Y(Player) to Y(player) + Gravity(Player) /which is one/

So he is going down one pixel on each gravity loop which always loops 10 times. Is this what you wanted me to do?

Image Edited by the Author.

 
n/a

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
4th July, 2006 at 03:41:27 -

No, that means he will always fall at 10. You want it like this...

Player not overlapping backdrop + gravity < 10 = add 1 to gravity
gravity > 0 = start loop(fall) gravity times
on loop(fall) = set y postition of player + 1
on loop(fall) + player overlapping backdrop = stop loop(fall) + set gravity to 0

Image Edited by the Author.

 
n/a

Werbad



Registered
  18/09/2002
Points
  235
4th July, 2006 at 08:36:01 -

You need to move the character 1 pixel up when you stop the loop or the character will get stuck 1 pixel into the ground...

 
n/a

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
4th July, 2006 at 09:05:21 -

Or make a loop Character is overlapping background start loop "thingy" X times.
On loop "thingy" set position of Character to Y.pos - 1

Where X is the maximum gravity which is 10 in your case.

 
thinking is like pong, it's easy, but you miss sometimes.

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
4th July, 2006 at 12:37:55 -

There isn't a need for a fastloop to unsink an object... just use a fastloop for falling, and check collisions on the loop.

 
n/a

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
4th July, 2006 at 12:41:02 -

Yes, assuming you're detecting collisions correctly on a fastloop, you shouldn't ever need to unsink.

This is actually all very useful to me as well, because I've never got this to work either.

 
http://www.davidn.co.nr - Games, music, living in America

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
4th July, 2006 at 15:42:48 -

To give an actual example (and not to hijack the thread, honest) can anyone tell me what immensely obvious thing I'm doing wrong here? Because I've no idea. The player still sticks down into the platform, and I'm sure that event #14 should work to prevent that.

Image

Image Edited by the Author.

 
http://www.davidn.co.nr - Games, music, living in America

Greasy



Registered
  15/02/2005
Points
  322
4th July, 2006 at 17:00:59 -

Well I managed to get my guy to barely stick in the ground. He only goes in about 1 pixel.

 
n/a

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
4th July, 2006 at 17:13:36 -

I solved my problem eventually - always remember to update the positions of your detectors on the fastloop as well!

It's possible that this is your issue too, though I'm not sure exactly how you're doing it.

Image Edited by the Author.

 
http://www.davidn.co.nr - Games, music, living in America

-Nick-

Possibly Insane

Registered
  24/11/2002
Points
  2468

VIP Member
4th July, 2006 at 17:50:13 -

Yes, you have to make sure you put an event to updates the sensors directly before any event which tests their location, or it will act as if the object hasn't moved.

 
Project: Roller Coaster is on it's way!
http://www.projectrollercoaster.co.uk/
http://www.craftsncreatures.com

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
4th July, 2006 at 21:04:46 -

Well you have several options, it's up to you. I suggest to try them all.

 
thinking is like pong, it's easy, but you miss sometimes.

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
5th July, 2006 at 05:35:26 -

"Well I managed to get my guy to barely stick in the ground. He only goes in about 1 pixel"
It may depend on your order of events. I always put my detectors 1 pixel from the edge of my sprite, not on the edge of the sprite, but it all depends how you've set up your movement.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click