About 'is_on_ceiling()'!

In this video (objectives)…

Stop Bunny from floating along the ceiling

After watching (learning outcomes)…

How to use is_on_ceiling()

(Unique Video Reference: 8_HD_GDT)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

Instead of using is_on_ceiling() I discovered that saving the result of move_and_slide() solves most collision and animation problems I had.

motion = move_and_slide(motion, UP)

With this code I also changed gravity to apply all the time. Since motion.y is set to 0 when on the floor or ceiling and no longer build up to infiinity.

I also changed the animation script to be more precise and avoid a few problems

func update(motion, is_on_floor):

if !is_on_floor:
	play("jump")
	flip_h = false
elif motion.x > 1: # Avoid impecise results, barely noticeable
	play("run")
	flip_h = false
elif motion.x < -1:
	play("run")
	flip_h = true
else:
	play("idle")
	flip_h = false

I hope this code can be of use to improve this already great course.

3 Likes

Yann, please, can you help me out?

By some trials and errors, i found this solution that works better but i don’t fully know why. The video’s solution lets the bunny to walk horizontally while attached to the ceiling. So, i guess it lets bunny floats in the air till his collision mask have no contact with the platform’s. I’ve just remembered that gravity was applied per second, so, maybe this way you let gravity start working by removing the bunny from the ceilling(executing the else condition).

4 Likes

same issue here! this solution was a life saver!

sound, nice workaround and cheers for sharing.

as far as i can remember when i was going through that, Yann also moved the player slightly out of the collision state as well to allow gravity to take hold.

Privacy & Terms