How to allow an object to have a mesh

0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi all!

    I'm trying to make a drawing plugin using the addon SDK v1. I want to be able to modify the mesh of the instances of my object type at runtime. To do this, i created a mesh using wi.CreateMesh(2,2).

    When this method is called, i receive the error "object does not support mesh". Digging a bit into the worldinfo.js code i find this:

    CreateMesh(t, e) {
     if (t = Math.floor(t),
     e = Math.floor(e),
     !this.GetInstance().GetPlugin().SupportsMesh())
     throw new Error("object does not support mesh");
     this.ReleaseMesh(),
     this._meshInfo = {
     sourceMesh: C3.New(C3.Gfx.Mesh, t, e),
     transformedMesh: C3.New(C3.Gfx.Mesh, t, e),
     meshPoly: null
     }
     }
    

    So it seems that the plugin itself has a flag that tells Construct if its objects support mesh or not. However, i can't find anything in the docs related to this. Is it possible to allow a custom object type to use meshes?

    Doing the same thing using a behavior on a sprite works since the sprite object by defaults allows the usage of meshes, so I wonder how i can achieve the same thing, but without a behavior and on a custom drawing plugin.

  • Not all objects support meshes. You can pick an instance then {instancePicked}.plugin.supportsMesh.

    construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/object-interfaces/iplugin

    The documentation can be hard to navigate on what regards to addons, you will have to look into the scripting documentation to complement the addon docs.

  • Good to know, thank you. I guess that means that there isn't a way to manually allow a certain plugin to use meshes for now (e.g.: by specifiying some plugin _info) (?)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Correct. If the plugin doesn't support meshes, there's nothing you can do to force it. I'm not aware of any exposed api to create a mesh on a custom plugin. But you can explore inheritance... could work.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)