#localAnimator.addDrawable not rendering correctly because of x coordinate of player's position

16 messages · Page 1 of 1 (latest)

plucky birch
#

How do I work with localAnimator and world coordinates? Depending on where I am the UI elements I rendered disappear. I've observed this even with my prior mod, Project 42. I need help understanding the coordinate system and how localAnimator.addDrawable() works with it.

I've come up with a finicky solution specifically for project 42, worldifying the coors of the line indicator for the alt ability, where alfa and beta are the vectors to worldify:

function worldify(alfa, beta)
  local a = alfa
  local b = beta
  local xmax = world.size()[1]
  local dispvec = vec2.sub(b, a)
  if a[1] > xmax/2 then 
    a[1] = -1 * (xmax - a[1])
  end
  b = vec2.add(a, dispvec)
  return {a, b}
end

I forgot why this works, could someone help me understand? thanks

It's 3am and we have 7am classes tomorrow so I just typed away my question and hope for an answer tomorrow (i'll add more details and clarifications when i get up 💀)

flint merlin
#

vec2.sub doesnt work well on world border sometimes

plucky birch
#

i've mostly been using vec2.add tho

#

haven't really used vec2.sub in my localanimator calculations so far nvm im blind

plucky birch
#

also not just the world border; sometimes it doesn't render anything in entire sections of worlds

#

what does a world's coordinate system look like? given an x-size x?

regal knoll
#

uhhhhhhhh, go use world.xwrap(x) to have x within world buondaries

#

for example with x being 1337 in a world size of 1000, it'll give you 337

#

and what is dispvec even, or what does the vec sub do there

#

use world.magnitude(vecA, vecB) to get distance between points, and world.distance(vecA, vecB) to get the separation between those two values as {X, Y}

lean lava
#

i think just using world.distance instead of vec2.sub works

#

i think world.nearestTo also might be useful

#

i dont remember lol

plucky birch
#

aight, will try

#

also hi pat i remade the hitscan mechanic of one of your guns if u dont mind