Registered Users
  • Content count

  • Joined

  • Last visited

Community Reputation

2 Neutral

1 Follower

About Xilexio

  • Rank
    Junior Member
  1. I want to know how to detect if the sprites used are facing the camera. In Extended Sample Character terms, I want to know when headbase-2 is used instead of headbase-0 or headbase-1. Using that information, I can do some hacks with animation that are hard to achieve in the current model (such as showing different beard from behind and from the front). GetCurrentFacing only says where the character is going/where is the thing the character is observing. But it does not change during emotes whose animation uses front sprites. And there is even a single fish catching animation that uses both front and back sprites, making it even harder to achieve. And I kinda don't want to get updated list of all animations and do a huge if.
  2. I need a code to do an action when the character is facing away from the camera (e.g. when going upwards). This is kind of separate from my other problem with changing z-indexes of layers in my other topic. I have my current solution based on this topic: The current buggy solution is: In master_postinit: inst:ListenForEvent("locomote", OnLocomote) And the function itself: local function OnLocomote(inst) local dir = inst.Transform:GetRotation() local camera_rot = TheCamera:GetHeadingTarget() local relative_dir = ((dir + camera_rot) % 360 + 360) % 360 -- detect up to 90 degrees from the top if math.abs(relative_dir - 180) < 90 then print("facing away from camera") else print("facing to the camera") end end There are two problems with that: 1. When character is facing upwards and then doing some animation facing towards the camera. An example is using "examine" on an item - there is no locomote event before the talking animation. 2. This is not a problem for be, but noting this in case somebody needs the exact code. The above only detects when the character is facing more away from the camera than to the camera, so it produces false positives when the character's side is visible. I could adjust the angle to 45, but then I'd face some weird issues with the relative_dir above being like 0.001 degree different than actual, which happens kind of randomly depending on camera rotation, when using W+A or W+D keys. Plus, I can get a lot of false positives when user is using mouse to move the character (when there is an obstacle on the way). Are there any events or maybe just properties of AnimState that detect if the sprites used are the ones for facing away from the camera? EDIT: I found out about ThePlayer.AnimState:GetCurrentFacing() == 1 usually when facing upwards, but it is broken when doing emotes/talking. It seems that the character is facing upwards when examining stuff that is above, but the animation is playing with sprites facing the camera.
  3. You mean that I should draw arm over the beard in headbase when facing upwards? This won't work, as the arm is constantly moving, and sometimes it's holding items. It'd look like an arm and parts of another arm then. It'd be even worse than occasional double beard when facing front.
  4. I am making my first character mod, where the character has long hair, a permanent beard about the length of Wilson's largest beard, and a mustache. The natural z-index order of layers should be as on the first image below: mustache, nose and face on the top, then hair, then beard. However, the beard in DST is a layer above everything, so I put the beard into the headbase. Everything looks fine from the front and side, but when looking from behind, it turns out that headbase is in front of arms, resulting in beard appearing in front of arms. I made my character from the Extended Sample Character template. How can I fix that? Ideally, I'd like to change the z-index of headbase to be behind arms when facing upwards. I already tried a few things: 1. OverrideSymbol("beard", ...) - like Wilson's beard - this did not work well, because it was in front of mustache and hair. When I made mustache part of beard, it was even more messed up, because it was getting separated from the nose when the character was "breathing" or doing emotes, and still was in front of the hair. 2. Editing z-indexes, ordering on xml elements and pretty much everything possible in scml file - I was editing the xml manually in various ways, but the changes were present only in Spriter, not in the game. I think the game does not care at all about ordering and z-indexes of layers in Spriter, and has real z-indexes hardcoded for each layer. Is that the case? 3. Making front and side like described above, and using Wilson-like beard only when the character is facing upwards. I based this idea on assymetric character design posted on this forum. I did this by AnimState:Hide("beard") (and Show), depending on the direction the character was facing during locomote events. However, it does not work when character is doing some kind of animation when facing upwards (e.g. talking), because then he has a double beard when facing front, because last locomote event indicated going upwards. 4. Splitting beard or mustache in 2 or more layers - it just does not work, since the layers are moving in different directions in game (e.g. when the character is "breathing"), messing up the lines. How can I make the beard show properly below hair and mustache during all animations?
  5. tl;dr: You compare exactly floating points, resulting in weird behavior. When the player goes upwards diagonally, the character sprite is directed either upwards or to the left/right. This is inconsistent. More specifically, if (inst is the player) (inst.Transform:GetRotation() + TheCamera:GetHeadingTarget() + 360) % 360 falls between 135 and 225, it shows facing upwards, if inst.Transform:GetRotation() is non-negative. If it is negative, it faces upwards if (360 - inst.Transform:GetRotation() + TheCamera:GetHeadingTarget() + 360) % 360 falls between 135 and 225. The problem is that while camera rotation is exactly 0, 45, 90, etc., the player rotation is always off by a fraction of a degree. It was important for me, because I am doing a mod, where I want the beard to appear only if the sprites are in the upwards position, so I need to detect when the player is shown going upwards relatively to the camera.