#doom-like entity sprites

1 messages · Page 1 of 1 (latest)

short roost
#

im trying to script doom-like sprites for entities (players, objects, etc.) that have multiple states depending on the viewer's position relative to the front of the entity
ive tried a couple times which all ended up catastrophically unsuccessful
i think the general idea is to get the vector between the player and the entity then use the vector to change the offset of a spritesheet on a billboard gui, but i have no clue how to translate this into studio
i know theres already a developer forum thingy up for this, but i still dont really fully understand
any help would be appreciated, thanks!!!

extra info:
i feel like i might need a module to do this, but im not sure. either way, ill be doing this with a lot of active objects (which means i might also need tables), so a module would probably work well

#

repost of the same question from studio help

limpid mica
#

Dot product 👍

#

actually no

#

just take the direction of a line between the player and entity (only on XZ plane), subtract it from the rotation of the entity, and then it should be pretty easy to assign sprites from there

#

holup

#

dont listen to me

short roost
#

i might be able to get the math stuff done myself
the issue im having right now is figuring out how to translate all of it into studio

limpid mica
#

do you not know lua?

#

or programming in general?

short roost
#

i know a bit but im relatively new and i dont really fully know how i can get scripts to interact in the way i want them to

#

ive tried just putting it all into a frame in a billboard gui in a part but i dont know how to get localscripts to do anything outside of the starterplayer folder, and it wouldnt work on a server script since i want this to be able to work with multiplayer

#

it would probably cause desync if i used a server script for an single player game, anyway

worldly pike
worldly pike
short roost
#

the thing is that i dont want it to change for everyone

ocean sparrowBOT
#

studio** You are now Level 2! **studio

short roost
#

if there are two players looking at a sprite from different angles, i want them to see the sprite of the angle that theyre viewing

#

meaning it needs to be client side

worldly pike
#

then do it on the client by just referencing the sprite. Like put all of your sprites in a folder inside workspace and reference that folder in a local script

short roost
#

hm

#

ill try it

worldly pike
#

👍

short roost
#

not gonna mark this as solved

#

more feedback from more people would still be nice

worldly pike
#

alr

half arrow
limpid mica
half arrow
limpid mica
half arrow
worldly pike
limpid mica
limpid mica
#

you cant tell if you should use the sprite for the left or right side of the entity with just dot products

worldly pike
#

like you see the back and the side of the enemy

limpid mica
#

it's a sprite

#

it only faces towards the player

#

which is why doom uses 8 sprites for each entity state to represent rotation

worldly pike
worldly pike
limpid mica
#

billboards are always facing the player

worldly pike
#

But i just mean that if the dot product is like lets say 0.8 of that enemy part and the player then you could change the sprite to look like its looking forward but in a slightly rotated way

half arrow
#

could you restate your problem? What I’m getting at is based off the players look vector, they sprite should rotate around?

#

Originally my thought of using dot product is wrong sorry.

#

I think I’ve thought of a new method that could possibly work.

#

First you take the lookvector of the camera and the lookvector of the root part, and you get the dot product between them, next you get the angle from the dot product using math.deg(math.acos()). Now you map the inverse of this angle onto the enemy

#

Also to see if the dot product is to the left or right, you should use VectorToObjectSpace to localize the unit direction of the humanoidRootPart and Camera lookvector and see if the x of the new vector is greater or less than 0

#

0 means that its to the right

#

and <0 means its to the left

short roost
#

hopefully this clarifies stuff

half arrow
#

what do you want to do with the numbers?

short roost
#

change the sprite of the entity that the player is viewing

#

on the client side

short roost
#

depending on the two vectors

#

which should be enough information to do what i want, but im not sure

half arrow
#

ok, so just use dot product?

short roost
#

seems like it would work fine

#

but i dont know how to get localscripts to work outside of starterplayer

#

havent used studio for a while

half arrow
#

you can't use local scripts on the server

#

you have to use remote events for them to communicate