spawning positioning

Hello again! In a scrolling platform type game I'm trying to spawn some things always just outside the right side of the viewport (like clouds, birds, etc) so they enter the game from the right side of the screen, regardless of where the player is in the world. I've been parenting the spawner to the camera, setting UseParentSpace = true and setting the position just outside the viewport on the x axis and y axis is random within a range. This works well, except now I've added some water and my character can dive and swim down below the "ground" surface. (there will be other ways to go underground as well) Since my camera is parented to the character, the spawner follows along and clouds and birds spawn dutifully underground. What would be the orx way to limit the y positioning of these items to an absolute position, while keeping the x values relative to the player to keep it off the right side of the screen? I'm resisting writing my own logic for this so I can better learn how to use orx.

thanks for any help!


  • edited December 2019


    If I understand correctly your problem, you'd like the X axis of your spawner to follow the camera but its Y axis to be at a fixed position?

    If so, I believe you could simply use the IgnoreFromParent property:

    IgnoreFromParent = none|all|rotation|scale[.xyz]|position|position.rotation|position.scale[.xyz]|position.position[.xyz]; NB: Defines which parts of the parent's transformation will be ignored when transmitted to the object. Defaults to none;

    You can finely tune which parts from the parent's transformation to ignore, but I believe in your case, you simply want:

    IgnoreFromParent = position.position.y

    With this, your spawner's Y value will remain absolute and you can then control the range where you're going to spawn your clouds and birds. Lemme know if that worked or if you encountered another issue.

    [Edit: The position of a child object is affected by all three components of the parent's transformation: rotation, position and scale. That's why, in addition to position which ignores all three at once, you also have position.rotation, to ignore the parent's rotation in the child's position's computation, position.scale, for the parent's scale component, and position.position for the parent's position component. In your case, you only want to ignore the parent's position affecting the child's position, hence the "weird" position.position value.]

  • Ah, I was on the right track but I didn't realize you could use the .x, y or z to fine tune it. That is pretty cool. I will try it!

  • Yes, that works just the way I needed it to. Thanks!

  • Excellent ! Lemme know if you have other questions.
Sign In or Register to comment.