• Runtimes
  • Parent independent Child x y positions

Related Discussions
...

Hi,
I'm using Gamemaker. In Gamemaker Spine runtime is very limited. I want to give parent independent x y positions to bones for some procedural animations for our game (like exploding body parts etc.)
These are what I have in Gamemaker Spine runtime;
world x
world y
world angle x
world angle y
local x
local y
local angle
bone's parent

for each bone...

I solve a child bone's rotation to independent from parent with world angle x+local angle.. this makes bone rotation doesn't affect by its parent. But when I try for positions I can't get an usable result.

How can I change a child bone's x y positions without affecting by its parent?

Gamemaker uses 3.7 runtime for now and I have Spine Essential version
Regards.

Your terminology is not quite clear. By definition a local position is relative to the parent while a world position is relative to world 0,0. You want to position a bone at a world position, regardless of the bone's parent? You'll want to set the bone's local position, so you need to convert your world position to the bone's local position. The Spine Runtimes have Bone worldToLocal which converts a world position into a local position. It would be used like:

local = bone.worldToLocal(worldX, worldY)
bone.x = local.x
bone.y = local.y

I'm not sure if GM exposes this. You can see the code here:
spine-runtimes/Bone.java at 3.8

unfortunately GM doesn't support these extra functions. This is the main problem I guess.GM only give values like above which are worldx worldy etc..
I must do this by myself with code. What is the formula for local = bone.worldToLocal(worldX, worldY)? I need this I guess.

I linked the Java code above. You can find the same code in TypeScript, C, C++, etc in the same GitHub repository.