question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to check if my object is on the "floor"?

See original GitHub issue

I currently use if(myobj.body.velocity.y == 0) most time this works except if my object is on top of some object like this:

image

as you can see in the console the velocity.y is changed in every frame update even my obj is not moved, I think this can be fixed by setting some parameter for the world?

what caused this problem? and what is the right way to fix? thanks a lot.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

4reactions
fabienjuifcommented, Oct 8, 2018

@jcyuan I mean, you can:

  1. set a type to your floor, body.type = ‘floor’
  2. use collide events, and then use the flag to detect the floor: http://brm.io/matter-js/docs/classes/Engine.html#events
  • collisionStart
  • collisionEnd
  • collisionActive
  1. Set a boolean into your “player” to mark it “on the floor” indeed

What means tuts? My game doesn’t have gravity, and I use circles for the heros 😃

2reactions
jcyuancommented, Oct 11, 2018

@fabienjuif ‘tuts’ means tutorials LOL. yepp, I changed my game logic, thanks man~

Read more comments on GitHub >

github_iconTop Results From Across the Web

Checking if object is in air or on ground? - Unity Answers
If your ground is tagged "Floor" you should be able to jump no matter if it is a angular surface or not. ......
Read more >
How to detect if object is grounded by raycast - YouTube
In this tutorial we discuss what raycasting is, and how to use it to detect whether an object is touching the ground.
Read more >
3 Easy Ways to Check if a Floor Is Level - wikiHow
1. Set a 4–8 ft (1.2–2.4 m) carpenter’s level horizontally on the floor. Pick a spot in the middle of the floor or...
Read more >
unity - Using collision.contacts to determine if on a floor
Doing this based on contact direction might get tricky, depending on the shape of your player collider. Imagine going up a flight of...
Read more >
Using Kinect to detect objects on the floor - Stack Overflow
There is several approaches to find the brightly colored objects. If your sensor will record a static scene, it's possible to use Background ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found