Announcement

Collapse
No announcement yet.

Question for "Doom like" sprite system

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    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:

    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?
    Attached Files

    #2
    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
    Website [ LINK ]
    Twitter [ LINK ]
    Support ! [ LINK ]

    Comment


      #3
      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:


      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. :P
      Attached Files

      Comment


        #4
        here
        Click image for larger version

Name:	s1.PNG
Views:	1
Size:	136.0 KB
ID:	1061193
        Click image for larger version

Name:	s2.PNG
Views:	1
Size:	214.2 KB
ID:	1061194
        Last edited by Mhousse1247; 11-18-2014, 04:45 PM.
        Website [ LINK ]
        Twitter [ LINK ]
        Support ! [ LINK ]

        Comment


          #5
          Cool, thanks!

          Comment


            #6
            Can anyone help figure out what values I will need to break this down into 8 angles?
            --
            CDRose | Environment Artist
            http://cdrose.portfoliobox.me/

            Comment


              #7
              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.

              Comment


                #8
                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:

                Click image for larger version

Name:	sprite-sides-1.png
Views:	1
Size:	233.2 KB
ID:	1121102

                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:

                Click image for larger version

Name:	sprite-sides-2.png
Views:	1
Size:	158.1 KB
ID:	1121103

                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
                ProBoon, Old-School FPS, Open Source & Tutorials
                Support Project Boon on Patreon

                On Steam Soon, Click Below

                Comment


                  #9
                  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:

                  Click image for larger version

Name:	2017-02-02_16-42-41.png
Views:	1
Size:	126.3 KB
ID:	1122443

                  Click image for larger version

Name:	2017-02-02_16-43-02.png
Views:	1
Size:	190.9 KB
ID:	1122444

                  Click image for larger version

Name:	2017-02-02_16-43-18.png
Views:	1
Size:	244.3 KB
ID:	1122445

                  Click image for larger version

Name:	2017-02-02_16-43-44.png
Views:	1
Size:	136.9 KB
ID:	1122446
                  ProBoon, Old-School FPS, Open Source & Tutorials
                  Support Project Boon on Patreon

                  On Steam Soon, Click Below

                  Comment


                    #10
                    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

                    Comment


                      #11
                      I have tried adding a 90 degree and 180 degree compare node. It works with the front, just not with th back. Any help?
                      Last edited by JiMiB Games; 05-09-2018, 12:26 PM.

                      Comment


                        #12
                        Click image for larger version

Name:	8sides1..PNG
Views:	2
Size:	132.4 KB
ID:	1473608Click image for larger version

Name:	8sides2.PNG
Views:	2
Size:	173.9 KB
ID:	1473609Click image for larger version

Name:	8sides3.PNG
Views:	4
Size:	195.9 KB
ID:	1473610



                        8 Sides anyone? Credit to masterneme for the original code. This is just an adaptation of his!

                        Comment


                          #13
                          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)
                          Last edited by Moddingear; 05-10-2018, 11:50 AM.

                          Comment


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

                            Comment


                              #15
                              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 JiMiB Games, 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

                              ProBoon, Old-School FPS, Open Source & Tutorials
                              Support Project Boon on Patreon

                              On Steam Soon, Click Below

                              Comment

                              Working...
                              X