Forums

OverviewFelgo 2 Support (Qt 5) › Visibility of an entity

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18585

    Marcin

    Hi,
    Have a question about entity and when is it visible.
    In my scenario I have many entities outside of what user can see, basically “outside” of scene(lest say y position is -1000), for example.
    The problem is Qt still recognizes this entity as visible.
    Is there an easy to way to tell if entity is really visible, like on the screen?
    Or I need to do things like bodyAt to find the x and y if there are visible to the user.

     

    I have some logic which should work only when entity is visible, but it works when user doesn’t see the entity just yet, so that causes some issues.
    I am also concerned about performance.
    From what I know Qt doesn’t execute some operations for entity if it’s not visible, in this case(entity not visible for user) those optimizations are not active but they should?

    #18588

    Alex
    Felgo Team

    Hi Marcin,

    since you are already using physics, I’d recommend using a sensor collider. You could either add 4 colliders at the edges (or rather a bit outside) of your screen, or a single one filling (or even a bit bigger) your screen.

    For the latter option, as soon as your entity collides with the sensor you know it enters the screen, and as soon as collision ends it left the screen. With 4 distinct colliders you will need some more logic to know if it either entered or left the screen.

    Physics uses all C++ behind the scenes, thus this will have better performance than running checks from QML on every frame.

    Is this sufficient for your use case?

    Cheers,
    Alex

    #18592

    Marcin

    Hi Alex,
    Thank you for hint.
    Will look closer into it.

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support