#Stupid math question

27 messages · Page 1 of 1 (latest)

viral jewel
#

I am making a td game in minecraft. For that I made some projectiles and wanted to add the ability to fire left and right projectiles. For some reason this doesn't work and the projectiles fly in wrong directions, but sometimes its fine. He is how I calculate the movement:

                  let dx = (x + w / 2) - 100
                  let dy = (y + h / 2) - 100
                  let distance = Math.sqrt(dx * dx + dy * dy)
                  dx /= distance
                  dy /= distance```
For the normal projectiles this works fine, and for the left and right projectiles I just do `movementX:dx*-1,movementY:dy`, `movementX:dx,movementY:dy*-1`
If you have any idea why its not working, please tell me.
vital bloomBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

viral jewel
robust urchin
weak garnet
#

at this point, just make a mod

viral jewel
#

Why?

#

It works just fine

#

This is just a mathematical issue

robust urchin
#

i find this interesting you can do this with just kubejs

#

a mod would be a lot cleaner i bet but this is cool

viral jewel
#

I also got a selection screen

robust urchin
#

oo

viral jewel
#

The enemys can have 4 diffrent effects(burning, poison, stun, freeze) and they can have shield, armor, higher speed

#

And they can spawn more on death and can be air, ground or invisible type

#

Anyways, any idea how to solve this issue?

robust urchin
#

not quite sure tbh

#

if its math maybe ask chat gtp

viral jewel
#

I asked it, it said it should work

#

Idk

#

Also isn't there

#

??ai

wide starBOT
# viral jewel ??ai

NEVER use any AI to generate KubeJS code. They currently know very little about it, and what they do know is often outdated or false. You can instead look at the KubeJS wiki or ask for help in #1047320998199955458.

viral jewel
#

I think I will just leave this issue open and hope some genius has an idea, meanwhile I can code other stuff

robust urchin
#

to generate the math equation

#

is what i mean

red ore
#

what exactly is wrong with the projectiles? didn't quite spot that.

viral jewel
#

The top right picture is what it should look like. One middle projectile and exactly 90° left and right should be another projectile