I’m hoping someone here can help me out or point me in the right direction. My project is a Mobile 2D top down space shooter which has a main BP that handles all the logic of the game, player spawn, enemies spawns and the background the player plays in. It also has vector locations for everything that needs a transform to spawn. At the start of the level the main BP gets the screen size and uses a Enum to pick which background to spawn based on screen size. It also scales itself to fit in the background, which causes the actors it spawns to scale also.
Most of the events and movement in the game are ran by timelines, other then the player movement and projectiles. The Player movement is handled by a InputAxisSpeed Variable Delta Seconds which is Finterp then added to movement input. Projectiles are handled by the projectiles movement component initial speed.
My problem is that everything moves at different speeds depending on the screen resolution, time lines don’t add up, projectiles fire at different speeds and the player movement is faster or slower. It seems to me that it has something to do with tick but how would i go about normalizing it through all the different resolutions, or do i need to figure out some type of time dilation? Any help would be appreciated.
do all your calculation in a normalized screen space.
so basically remap say 0~800 and 0~1280 back to 0~1 in float, then apply your calculation of speed, and in the end remap back to current screen resolution.
All 3d render basically do this as well.
Thanks, that makes sense. Is there a way to do this globally to time other then dilation or do I need to remap every single timeline I have based on screen space?
So I want to take your advice and do this properly. I have attempted to normalize the speed of my player sprite, by using 1080 x 1920 as the normal and adjusting the speed value based on that. When I adjust the speed down for a 480 x 800 res it seems to work perfectly but when I adjust it for my nexus 10 resolution which is 1600 x 2560 its still a bit slower. It almost feels like the speed is capped and I have a feeling it has to do with the character movement component but can’t pin point what it is. BTW this is how my BP looks, not 100% sure I’m doing this right.
yes you are right about movement speed, for character movement, there is a “max walk speed” by default. It was there so when you have input to move forward, it won’t continuously speed up.
what you have to deal with is that when you have a larger resolution, you need to move more pixels, which would hit the maximum limit that capped off automatically by the movement component.
You can however set the max walkspeed after you set screenSpeedX/Y, the value can be calculated with your movementSpeed*max(screenSpeedX, screenSpeedY), if you only concern X more, then just multiply with screenSpeedX.
another method would be you set your own max speed for X and Y, and set max walk speed to a really big number.
right before you add movement input, you get your current speed and add your input(amount you want to add), clamp it to your max value and then substract current speed.
in math:
speedToAdd = clamp( currentSpeed + inputSpeed, 0, maxSpeed) - currentSpeed
if you control velocity directly, maybe it’s easier.
Good luck.
Yep that was it, or in my case maxFlySpeed*screenSpeedX = newMaxFlySpeed, so this combined with the added screenSpeed solved my sprite movement problems across multiple resolutions. This is my first project so when I tried to search for an answer for this I did not know how to word it or what exactly I was looking for. So I really appreciate your help. Im going to tackle the Timelines next and see if I can get them to be some what close.