Simple question about meshes

0 favourites
  • 6 posts
From the Asset Store
mesh 3D objects "hemisphere, oval, tunnel and other various shapes."
  • Hello!

    I'm trying to something frustratingly simple: set the x and y coordinates of a mesh point for a sprite. To try and test this, I've set up a square sprite with a 2x2 mesh grid and I want one of the points to be set to the mouse position. However, I'm not able to do this without the mesh point going infinitely off the screen. Is it possible to simply set the position of a mesh point? I feel like this should be possible. What am I doing wrong?

    Tagged:

  • "Mesh distortion" - you can see it clearly in this example.

  • Mesh points are relative to the position, angle and size of the object. That can be useful or inconvenient depending on what you want to do.

    If the sprite isn’t rotated then this should work to get an x,y position on the layout converted to a mesh point location.

    MeshX = (x-sprite.x)/sprite.width

    MeshY = (y-sprite.y)/sprite.height

  • Mesh points are relative to the position, angle and size of the object. That can be useful or inconvenient depending on what you want to do.

    If the sprite isn’t rotated then this should work to get an x,y position on the layout converted to a mesh point location.

    MeshX = (x-sprite.x)/sprite.width

    MeshY = (y-sprite.y)/sprite.height

    Much appreciated? What if it is rotated?

    What I'm trying to do is create a sort of cursor made up of a circle that follows the mouse and a kind of beam that is fixed to the player but has it's width set to the distance between them and the cursor, which it is always pointed towards. I thought it would be nice to use meshes to ensure that the end corners of the beam are always set to the height of the cursor. (apologies if the explanation doesn't make sense)

    Is this not possible since the beam will almost always be rotated?

  • "Mesh distortion" - you can see it clearly in this example.

    Thanks - I had a look but it seemed more complex than what I needed. I think I may have falsely assumed that simply setting the position of a mesh point with the set mesh point function was a simple thing to do.

    I'll try to break it down and see how easily I can replicate in my project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If the sprite is rotated then the formulas look a bit more involved. It unrotates the position, before scaling.

    Meshx = ((x-sprite.x)*cos(-sprite.angle)-(y-sprite.y)*sin(-sprite.angle))/sprite.width

    Meshy = ((x-sprite.x)*sin(-sprite.angle)+(y-sprite.y)*cos(-sprite.angle))/sprite.height

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