Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragon doesn't always face to the target point #14

Open
tschaffter opened this issue Apr 1, 2015 · 6 comments
Open

Dragon doesn't always face to the target point #14

tschaffter opened this issue Apr 1, 2015 · 6 comments

Comments

@tschaffter
Copy link

I set a station and traveled to it successively from a position at the North, South, West, and East of the station. Each time the dragon was facing correctly to the station point. However, the dragon is not facing the destination point when leaving from North-East, South-East, South-West, and North-West.

The station in the image below is located on the top of the emerald block.

2015-04-01_07 34 15

2015-04-01_07 34 45

@ChanceSD
Copy link

The dragon also flies backwards when travelling to a station in another world.

@Phiwa
Copy link
Owner

Phiwa commented Jan 2, 2017

I'll try to work on this issue during the next days to see if there is a fix for this.

@mhtvsSFrpHdE
Copy link

mhtvsSFrpHdE commented Sep 16, 2019

@tschaffter @NoChanceSD @Phiwa I'm working on this.
First I'll contact my mathematical consultant for a algorithm to calculate
direction change between (x+5, y+5) and (x, y) in realtime during the movement.

And try to update it for a flying dragon.

@Phiwa
Copy link
Owner

Phiwa commented Sep 16, 2019

In theory, you just set the yaw for the dragon and that's what we are already doing. I think, there might be an overflow (360+x =x) though since the calculation works, but only for some directions.
The basic calculation should be correct, that's why I did not fix it yet.

@mhtvsSFrpHdE
Copy link

mhtvsSFrpHdE commented Sep 16, 2019

@Phiwa She said something like

old = 0, new = 1
tanθ = (y1-y0) / (x1-x0)
arctan
result - 180 + 360

Then can get a value for forward direction angle.
Although I didn't understand one letter in the formula(my math sucks)
This should work.
My idea is track this in realtime if performance is allowed or play some tricks.
In the initial I use station target location and current location to calculate first direction.
When future updates, the first target location should be nearest station key frame.

Not sure if Minecraft even can adjust 3D angle (720 in 3D space).

@Phiwa
Copy link
Owner

Phiwa commented Sep 16, 2019

But this is basically what we are already doing...
We are recalculating the new direction on each server tick.
Please take a look at the current implementation before planning big changes.
You can find it in https://github.com/Phiwa/DragonTravel/blob/master/src/main/java/eu/phiwa/dragontravel/nms/v1_13_R1/RyeDragon.java (lined 82-104) or in other packages, depending on the version of CB/Spigot).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants