ToggleVisible with blinking effect

Hello everyone,

I think that this is my first message in the forum asking for help, and I don’t know if this issue is more related with the rendering part or it has something to do with the coding section, so I apologize if this is not the right place to ask…

I’m trying to recreate the classic pacman and after tweak arround with skeletal meshes and animations and several failed attempts, i’ve decided to use two independent static meshes for my character: one with the mouth open and one with the mouth closed, and then each 50ms swap the visibility of both meshes, and without movement it looks pretty good, but when I’ve started moving arround a blink effect appear to my player.

pacman.mkv (2.7 MB)

I’ve tryed with timers, with tick updates, with different methods ToggleVisibility, SetVisibility, SetActorHiddenInGame, … and all produces the same blinking effect. Maybe it has something to do with the rendering part or is the method I’m using to update the player position. I really don’t know where to start touching to achive the effect that I’ve wanted swapping the mesh smoothly without any frame without seeing the player mesh

If it’s needed I’ve leave the code for the tick method:

void APocmanController::Tick(float DeltaTime) {
	Super::Tick(DeltaTime);

	if (!MovementDirection.IsZero())
		SetActorLocation(GetActorLocation() + DeltaTime * MovementSpeed * MovementDirection);

	swapMeshesTimeout += DeltaTime;
	if (swapMeshesTimeout > 0.25f) {
		swapMeshesTimeout = 0;
		MeshClose->ToggleVisibility();
		MeshOpen->ToggleVisibility();
	}
}

Thanks for the help!

I can’t actually see any blinking in the vid, but… something to try:

Instead of hiding one mesh and then showing the other, try showing the next mesh first, then hide the first?

1 Like

if you just want to swap the meshes for the chomping effect just by hidding/unhidding the other
then I think is better to use UStaticmescomponent instead skeletal meshes and just swap the mesh in the same component with setMesh()

2 Likes

BTW I just did this simple test in blender for you:

here is the blender file and the export FBX in the case you want to go for the skeletalmesh animation approach.

Cheers!

Dany

PacMan.rar (151.6 KB)

1 Like

This is the first thing I’ve tried. I’ve thought that the tick function could execute independently of the rendering methods and I’ve shown the hidden mesh first and then hide the shown mesh but the result is the same… Another point for the rendering section.

1 Like

Thanks for the tips!

I’ve already have a skeletal mesh with blend shapes in case that i desist of trying the two static mesh method… but I want to achieve it using the first method. This project is just for testing and playing with the engine so avoid the method should be last option :rofl:

1 Like

After some tries more I’ve decided to use an skeletal mesh with the blend shapes and stop switching the mesh to avoid the blinking effect.

Thanks both of you for the help!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.