Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Has anyone else experienced there player Entity suddenly go invisible of screen?  (Read 1406 times)

0 Members and 1 Guest are viewing this topic.

S_BISHOP

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email

 I admit this is a strange question (laughs)
 Im just curious, if this has happened to anyone else during there project development life cycle, its honestly
 happned 2 - 3 times in 2+ years of a dev cycle, and its difficult to re-find the cause of it each time.

If so, im glad to know i'm not the only one, What happens exactly? 
The Player entity goes invisible and off screen, no collision now applies,
so i guess there isnt even a plysical player enity to collide, or further develop with.

In the past Ive found it has something to do with RAM, my project reads in level entitys from txt file, and removing the expensive ones such as particlespawns can somtimes resolve it or number of ai floating around on screen ?




fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Sounds like an uninitialised variable somewhere - possibly a bool. When you're building in debug mode quite often values are all zeroed out, and an uninitialised value here can go unnoticed, particularly if the default value should be false. In release builds, however, you might get the value you expect, or you might not - which causes the odd behaviour. Moving other objects around in memory is going to change the values which are current at the time the uninitialised variable is created. Again this might give the value you want, 'fixing' the issue, but the chances are it won't. Make sure to set the flag for your compiler to warn for uninitialised variables, which might help pinpoint the problem.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
It's not entirely clear what you mean.

Does the entity not render anymore?
Or does the collision fail and it goes off-screen (thus not rendering anymore)?

Either way it sounds like a logic bug.
If your entity can skip the collision, then there's an issue with your collision detection.
There's also something called the tunnel effect, where an entity may be able to "teleport" through a wall if it goes fast enough, due to your collision detection not being able to keep up with the speed and missing an obstacle in the way.
There can also be issues, if your logic depends on the framerate or just the delta time. For example if you grab the window, the code will stop processing, but the clocks will still keep running, so you potentially end up with a huge delta time, which can mess up some physics calculations.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

S_BISHOP

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Thanks for the replys.

I just took a look at running in debug mode, and looks as if the players destructor is called to soon or multiple times and that should not be,  i once solved this issue by making the player a shared_ptr and not a unique_ptr, for the reasons that it is passed in and out of functions and needs to remain in scope.

S_BISHOP

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
@eXpl0it3r   Thanks, i have uncounted the tunnel effect multiple times, and yes i did release and learn that about the window overtime, but thanks for renewing that in my mind.

 

anything