Code Monkey home page Code Monkey logo

Comments (3)

Dev-MarkoF avatar Dev-MarkoF commented on May 23, 2024 1

userData is part of the shape associated with the rigidbody. So in your case you won't find it in hit, but in the shape like shape.userData.
I know it works, since i integrated OIMO into a game engine and heavily rely on this feature to distinguish "Objects" by not only save the name of a body in the user data but a whole "gameObject".
You can use this shape.userData also in collisionEvents. Be also aware of the fact one body can have multiple shapes attached to them, each shape then has userData.

from oimophysics.

8Observer8 avatar 8Observer8 commented on May 23, 2024

Thank you very much! It works! I even can use my own data name, for example, myUserData instead of userData:

platform1Shape.myUserData = { name: "platform1" };
rayCastCallback.process = (shape, hit) => {
    console.log(shape.myUserData.name);
};

But I sure that by unspoken agreement, it's better to use the userData name like in another physics engines.

The documentation on shape has userData:

image

But It is strange that it cannot be found by searching the documentation:

image

from oimophysics.

8Observer8 avatar 8Observer8 commented on May 23, 2024

It is better to search in this file: node_modules\oimophysics\bin\js_modules\OimoPhysics.d.ts

from oimophysics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.