# Question for "Doom like" sprite system

Hello!

I am working on an FPS using a doom like system, were enemies and object are flat sprites that are always turned towards the player. It was quite easy to make the sprites turn towards the player. However, I am at a loss for how to change between sprites depending on the direction of the enemy actors relative to the player. Like this:

&stc=1

I guess I would have to divide the rotation of the enemy actor into zones depending on the angle (perhaps through the Clamp Angle node?), and then compare the players location to see if it falls within each zone - but I don’t know how to do any of that.

Anyone working on something similar, or have any ideas?

Hi
there is many ways to do it , here is one :

let’s say your enemy direction is his forward vector

Sprite A if , Dot(Enemy forward vector , (playerLocation - EnemyLocation).Normalized) >0.7

Sprite D if , Abs( Dot(Enemy forward vector ,(playerLocation - EnemyLocation).Normalized) )<0.7 && Dot(enemy Right Vectorc,(playerLocation - EnemyLocation).Normalized)<0

Sprite B if ,Abs( Dot(Enemy forward vector ,(playerLocation - EnemyLocation).Normalized) )<0.7 && Dot(enemy Right Vectorc,(playerLocation - EnemyLocation).Normalized)>0

Sprite C if , Dot(Enemy forward vector,(playerLocation - EnemyLocation).Normalized) <-0.7

Hi.

Thanks for the answer! I’m not sure how to implement your suggestion as a visual script.

I actually managed to fix a system of my own, using the visual scripting. It looks like this:

&stc=1

&stc=1

It compares the enemy actors rotation with the a Look at rotation with the player as target, using a Compare Float to check if the player is on the right or left side of the enemy, checking how much to the left or right the player is. Then, using two branches, the script find out what “zone” the player is in: <45, <135, or <135 (<-45, <-135, or <-135)

It works fine, but perhaps there is a more elegant way to get to the same result.

Cool, thanks!

Can anyone help figure out what values I will need to break this down into 8 angles?

Sorry for the bump but I would like to know how to get this to work with 8 different angles as well. I’ve been trying for a while and I just can’t figure it out.

Hi, sorry for necroposting, I was looking for this because I’m making a sprite based FPS so I tested your suggestions and found a very easy way to make it work. If you modify it, it will work with 8 sides as well:

And that’s it, here is the rest which are just some PrintStrings to test if it works, if you change them for Enums setting the sides then you can change the flipbooks and make the character behave like in old school games:

I’ll release a full and free project soon teaching everybody how to make a sprite pased FPS but if you can’t wait here you have a good way to have your Doom clone

Hello again, I’m posting because what I wrote before only works in World Space without taking into account the actor rotation, I made the changes to make it work properly:

Wow. this is super nice! i was looking in moddb for your progress. very cool. will u bring a tutorial on doom clone? it would be supergreat to implement multiplayer

I have tried adding a 90 degree and 180 degree compare node. It works with the front, just not with th back. Any help?

8 Sides anyone? Credit to masterneme](HTTP data format issues - C++ Gameplay Programming - Unreal Engine Forums) for the original code. This is just an adaptation of his!

Or just use an array and an inverse lerp into lerp to get the index of the sprite, it’ll clean up the code a lot. That just requires that your sprites be in the right order.

Such as if you have an array of any length, you get sections covering 360/<array length> and the index is floor(<actor look rotation>*<array length>/360)

Thanks for the advice, I’m new to the engine so I haven’t much experience.

Those angles look weird for 8 sides [USER=“1328208”]JiMiB Games[/USER], if you don’t want to wait for my video try these ones instead: 22.5, 67.5, 112.5 and 157.5.

I’m using dot products and branches so it may not work for you but it should. Also, instead of booleans, create an enum with all 8 angles and use “setters” with it. This way you can check directly what angle is being displayed because is the one in the enum variable.

Then you can use another enum with states so you can use select nodes and quickly change the flipbooks accordingly to the angle and what the character is doing.

More coming this weekend

Hi,

Have you made any progress on your tutorial for this. Dying to see how you’ve implemented this.

I overestimated my PC’s ability to edit video and the progress is slower than I anticipated but I’m finishing.

Hi masterneme.

Very cool project. I just checked out your demo you released in 2017. Excellent job on you work.

Is this project abandoned now ?. Was the project files ever released for this or any tutorials available ?

It would be cool to take a look how you put all this together.

Not abandoned, it’s quite the opposite, I’m preparing an IndieGoGo campaign right now so I had to reorganize my priorities.

I want to release a game before the end of the year and I stopped some of my tasks because they were taking me too much time of productive work.

I’m giving the final touches to a demo map for a pre-alpha gameplay video for the campaign and for the Coming Soon page on Steam.

The project files with the game logic will come thereafter but I can’t say when, sorry.

I’m thinking about making a Patreon with some kind of Early Access for people who want to see some of the stuff and don’t want to wait until I make it look pretty, now it’s very messy, ugly and unoptimized. Maybe after the campaign is over and if I see some interest.

Hi Mastermeme

That’s good news your still working on it. This is a cool project for sure and if you do decide to make a Patreon I’d pledge for early access and I’m sure others would too. I’m very interested to see how you got everything working so well because I’m planning on making an old looking 3d sprite styled animation using the unreal matinee. So animating all my sprites to look at the camera with the correct sprite angle and correct frame number to emulate the old doom style game is gonna take a lot of extra keyframing. Having the sprites with the angle logic built in makes a lot of sense to save on time.

From your posts on this thread I’ve got the sprite working with 4 sides fine and then tried with 8 sides and it works fine but when I added with the sprites rotation being taken into account the negative values isn’t being used. When I move around the sprite it goes from 0 to 180 but half way it reverses the value from 180 to 0. So I’m not getting the negative values -180 to -0. The condition always stays false and the sprites on the opposite sided didn’t get triggered

I’ve added a pic to show where I’m at. I’d appreciate any help in getting this working correctly so I can play around and do some tests with sprites in matinee.

BTW Thanks for sharing your blueprint posts