Download

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:

https://forums.unrealengine.com/attachment.php?attachmentid=17512&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 :

Sprite A if , Dot(enemy Driection,(playerLocation - EnemyLocation).Normalized) >0.7

Sprite D if ,Dot(enemy Driection,(playerLocation - EnemyLocation).Normalized) <0.7 && Dot(enemy Driection,(playerLocation - EnemyLocation).Normalized)> -0.7 && PlayerXloc < EnemyXloc (if x is horizontal axis)

Sprite B if ,Dot(enemy Driection,(playerLocation - EnemyLocation).Normalized) <0.7 && Dot(enemy Driection,(playerLocation - EnemyLocation).Normalized) > -0.7 && PlayerXloc > EnemyXloc (if x is horizontal axis)

Sprite C if , Dot(enemy Driection,(playerLocation - EnemyLocation).Normalized) <-0.7

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:

https://forums.unrealengine.com/attachment.php?attachmentid=17545&stc=1

https://forums.unrealengine.com/attachment.php?attachmentid=17546&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. :stuck_out_tongue:

here


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 :smiley:

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?

8sides3.PNG

8 Sides anyone? Credit to masterneme](https://forums.unrealengine.com/member/16667-masterneme) 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.

I’m finishing a tutorial about this, it will probably be uploaded to Youtube this weekend. I also explain how to create sprites from 3D models using CustomDepth.

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 :smiley:

Hi,

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

Thanks in advance.

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.