Yao-class-cpp-studio/GameX

[feat] Safe Ball Removal

Closed this issue · 3 comments

It is easy to add new ball by

auto new_unit = world_->CreateUnit<Logic::Units::RegularBall>(new_player->PlayerId(), glm::vec3{0.0f, 1.0f, 0.0f}, 1.0f,1.0f);

But, removing a ball is rather a difficult process since a RegularBall is associated with it corresponding Actor, Object.

How can we remove a ball safely?

We may do this by recording the id of the ball and call world_->RemoveUnit(uint64_t unit_id).

We may do this by recording the id of the ball and call world_->RemoveUnit(uint64_t unit_id).

It is an effective method! However, after calling the removal function, the physic ball involved in the calculation will be removed, but the image of the ball will be left on the board, which makes the board a little mess.

Besides, removing a ball will lead to unexpected seg_fault when app quits. It looks more like a critical issue in src/GameX.

Well, I am posting this issue because a multiplayer room must handle balls' quit. Such a headache, ahhhhhh!

This issue is ready to close. Actually we found a bug in actor removal in game_ball.cpp.
Refer to Original Code, and Fixed Code