Project: Paper2D

Hello ,

I am currently having an issue with Movement Component on a paper2d Project. I’m currently attempting to make an isometric game, and I have set movement component to flying, with no gravity. I have designed proper air braking to give walking effect a good feel but works only when its uni-directional input. Once I start a multi-directional input, movement component ignores braking and starts to “float” giving a drifting effect with character. Going from UP + LEFT to LEFT causes component to bank a little bit before course correcting to a full left direction. Same with any other multi-direction to uni-directional/multi-directional movement/direction. I was wondering if you had any suggestions to remove banking effect currently happening.

is my current c++ settings for my movement capsule.


// Configure character movement
	GetSprite()->SetEnableGravity(false);
	GetCharacterMovement()->DefaultLandMovementMode = MOVE_Flying;
	GetCharacterMovement()->GravityScale = 0.0f;
	GetCharacterMovement()->AirControl = 1600.80f;
	GetCharacterMovement()->bCheatFlying = true;
	GetCharacterMovement()->MaxFlySpeed = 600.0f;
	GetCharacterMovement()->BrakingDecelerationFlying = 500.f;
	GetCharacterMovement()->FallingLateralFriction = 0.f;

	GetCharacterMovement()->GroundFriction = 0.0f;
	GetCharacterMovement()->MaxWalkSpeed = 600.0f; //does nothing
	GetCharacterMovement()->BrakingDecelerationWalking = 3048.f;
	GetCharacterMovement()->JumpZVelocity = 1000.f;


	// Lock character motion onto  XZ plane, so  character can't move in or out of  screen
	GetCharacterMovement()->bConstrainToPlane = true;
	GetCharacterMovement()->SetPlaneConstraintNormal(FVector(0.0f, -1.0f, 0.0f));

	// Behave like a traditional 2D platformer character, with a flat bottom instead of a curved capsule bottom
	// Note:  can cause a little floating when going up inclines; you can choose  tradeoff between better
	// behavior on  edge of a ledge versus inclines by setting  to true or false
	GetCharacterMovement()->bUseFlatBaseForFloorChecks = true;

Any help in would be greatly appreciated.

Thank You,
Batista

Looks good, man! Excited to play final product!

That drift is controlled by friction in CalcVelocity() and ApplyVelocityBraking(). In air and water we use FluidFriction from current PhysicsVolume. If you want a different feeling to controls in air, you could override ApplyVelocityBraking() to use a custom friction setting there instead when in air (ie just call Super method with a different friction).

Thank you for reply, I’m starting to mess with CalcVelocity but ApplyVelocityBraking() is in-accessible to me(looks like its listed under protected.) For overriding purposes, how would look like in code? I’m a beginner with coding standard if helps pinpoint further solutions.

Actually I was wrong about ApplyVelocityBraking, you will only want to override CalcVelocity; ApplyVelocityBraking is only for actual braking when there is no acceleration. Friction is used for turning in CalcVelocity with code:



		// Friction affects our ability to change direction.  is only done for input acceleration, not path following.
		const FVector AccelDir = GetSafeNormalPrecise(Acceleration);
		const float VelSize = Velocity.Size();
		Velocity = Velocity - (Velocity - AccelDir * VelSize) * FMath::Min(DeltaTime * **Friction**, 1.f);


There is also fluid friction applied right after that, if bFluid is true.

In your case I would probably override CalcVelocity to set bFluid to false when flying, and use your own friction setting for turning. You could get fancier if you care to only do when there is acceleration (so you still have fluid friction when braking/coasting to a stop). Something like :



void MyMovementComponent::CalcVelocity(float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration)
{
		if (IsFlying())
		{
				bFluid = false;
				Friction = MyFlyingFriction;
		}
		Super::CalcVelocity(DeltaTime, Friction, bFluid, BrakingDeceleration);
}


may be a case where we could add a separate turning friction for flying mode, I’ll think about that for future.

THANK YOU VERY MUCH! worked perfectly :smiley: I’m going to post solution in answer hub and credit ya and what not.
Maybe one day I can return favor!
Thank you,
Batista

Hey!

I do not know what you did but now everything looks super crisp and most if not all of jitter is gone! (4.9) Whohooo! Happy days!

A problem that occurred though is that some of my sprites now have lost ability to edit their collision in sprite editor. lines are simply not there.But they still remember (and you can see in pie) collision shape that i had previously given to them. Any ideas why is happening?
Another question regards cooking. is first time i have seen something like (LogRenderTargetPool:Warning: r.RenderTargetPoolMin exceeded 479/400 MB (ok in editor, bad on fixed memory platform)) and was wondering what it is and what can affect regarding a paper2d project.

Thanks.

Hey ! Thank you for your kind words! Really appreciate it.

Very cool! It looks like things are really coming together. death animations cracked me up :slight_smile:

Cheers,

I changed how serialization worked for collision shapes and render geometry during 4.8 but tried to do back compat. for old format. I’ll see if I can repro it on some old assets, but if you could send in a repro that’d be great.

RE: frame buffer message, you should be able to ignore that in editor, you’ll typically see it if you have high resolution screens and/or stretch editor across several monitors as it needs more memory for frame buffers. If you see it in packaged standalone game then you should look at why you are using so much.

Cheers,

Also as a heads up, at end of your video it looks like every coin has a sound component. You should probably just play a one shot using PlaySoundAtLocation when a coin is collected, instead of spawning all of those audio components.

Cheers,

Thanks for heads up but i have options from both main menu and pause screen that can change audio volume from 100% to 0% in increments of 20%. If i use a one off i must figure out a way to implement . May i ask how resource intensive is an audio component? Because i have hundreds of coins in my levels.
I wish you could give us some more feedback regarding best practices. It is so difficult to do right thing without knowing what is costly and what is not. I had to try and figure out whole audio (nothing was available a month ago) process by myself and without sound notifies it was a pain, but i managed to make it work but apparently i did know that audio components have a cost.

P.S I know that you are a tough cookie to crack but a simple “keep up good work” or game is “looking promising” will probably make us feel a bit more confident ! :slight_smile:

RE: Sound components, not sure it’s actually going to be a hugely noticeable impact to remove them, but creating fewer objects is always better. PlaySoundAtLocation behaves same as if you had an audio component, RE: playing a sound cue or wave, so you can either use a sound class to globally control volume for a kind of sound, or you can use VolumeMultiplier on PlaySoundAtLocation node, wiring in current setting. I’d recommend using sound classes, but I’m not an audio expert.

Cheers,

I swear i never saw your reply. How embarrassing! XD
It turned out to be super easy for me to change from audio component to play on location so everything good.
May i suggest a small feature? I have a couple of BP that have more than 20 sprites and flipbooks inside them. Would it be possible to have a little eye next to them (like layers) so we could toggle visibility on or off for each? It is quite difficult to align them if you have more than a few.And a search bar would welcome as well(i am not sure if you have done already I am away from my computer now)
Thanks!

I don’t think components tree has had visibility or search added. Please start a thread in Feedback forum for those requests.

RE: geometry change when opening old assets. Adric wasn’t able to reproduce except with shrink wrapped sprites, which change their geometry if you edit a sprite that uses it due to a more conservative algorithm being used starting in 4.8, but fully custom and source/tight rectangles both seemed to load OK and not change when you edit them. If you’re seeing on other kinds of sprites, I’d appreciate a repro when you get a chance.

Cheers,

In my case things are a little different. Here you can see 2 neighboring tiles. One was saved with custom and it works. other one was saved with bounding box and it does not work.Now if i choose custom to one that does not work, it gives me error.

https://www.dropbox.com/s/5soipc2xjdy78j9/Collision%20editor%20error.rar?dl=0

Hi . As said, I wasn’t able to reproduce issue with assets saved in 4.7.6, then opened in either 4.8 or 4.9. From your screenshots, it appears that problem sprite is somehow in a state where it has baked collision preserved, but source shape is missing. I’m guessing that when anything triggers a geometry rebuild, it clears collision because it has no source shape to build from.

Could you start a thread on AnswerHub about issue and attach problem assets so we can investigate more thoroughly?

Hey Andric.
You mean upload actual png’s? We are talking about more than 30 sprites that are affected just on my lava tilemap.I cant upload publicly a fourth of my tileset! And even if i did i highly doubt that you could repo . I wish i was able to reproduce it with a default template and send it to you but unfortunately i cant. You see my project has so many sprites ,flipbooks and blueprints that it is almost impossible (in a reasonable amount of time that is)for me to always pinpoint reasons behind what is causing all of that.

To try and help as much as i can i recorded a small video.For record i have no clue why Unreal gives that parallel shape as collision to my tile.Mine are all square (obviously!) :slight_smile:

Another bug is . If you change something inside a blueprint and you press compile BEFORE you press play then game starts instantly. If you forget to compile and press play straight away then everything freezes, task manages shows unreal as frozen and depending of blueprint size it takes anywhere from 20 sec to 2 min(!) to start preview.

PLEASE forgive me for posting them here but it is so much faster and easier way since knows code inside out and what he has changed and not .It is extremely time consuming to try to explain to () staff all . And as i said before most of these issues do not arise in smaller projects for me to be able to reproduce them and just send file to aswerhub.
Thanks!

Nice shaking effect . I will check your code tonight :stuck_out_tongue:

Hey , guys.

I am not sure if is right place for post.

My Paper2D game uses 7 atlases and my apk looks really big. Yes, i found out that UE4 has some issues packaging android apps and there are some strategies to decrease 15-20MB.

But something catches my attention:

Those are my texture atlases and they are 10 times bigger than textures on disk.

Why is happening? Is there a way to decrease their size (compression or any other option)?

//Thanks