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

Sensor .islookingAt table not returning values when looking at entities. #30

Open
TorakWolf opened this issue Jun 20, 2014 · 8 comments

Comments

@TorakWolf
Copy link

I am not sure if this is propositional, but without that function I can't make one aim assistant program, or one "spider sense" warning program that alerts you about unwanted scrutinize of hostile hobs.

When the player/mob is looking at one block, all is ok...

@boq
Copy link
Member

boq commented Jun 20, 2014

It's not implemented. Sounds like good idea, may implement later. But we decided to freeze 1.6.4 (no new features, bugfixes only), so this one may be done after 1.7 port.

@TorakWolf
Copy link
Author

Is that hard to implement? I have a lot of mods that will not be upgraded to 1.6.4 by a good timme.

@TorakWolf
Copy link
Author

I am not sure, but can I use the yaw, yawHeah, and pitch to trace the vision target?

@TorakWolf
Copy link
Author

If yes, how can I do that? ( Sorry, no edit button on Android )

@nevercast
Copy link
Member

Create a 'ray' (vector) from the head position in the direction of yaw and pitch.
Then check if it intersects the bounding box of the entity, if the bounding box information is not given by OpenP you'll have to do this yourself, for the record, zombies and skeletons are apx 1.6 meters tall, as are players, spiders are 0.6 tall, ish. 1.5 wide. I think players are apx 1 meter wide.

Create an Axis Aligned bounding box in Lua, by taking the position of the entity, and subtracting/adding half the dimension in each direction to get two vectors, minXYZ and maxXYZ.

From here you want to check for a Ray-Box intersection. This all depends on how good your understanding of 3D constructs and trigonometry is.

Here is a paper on Ray Box intersection.
http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/

Pseudo-Code is provided on this article; if your programming ability and understanding are strong enough, you should be able to implement this in Lua without too much trouble. Note this takes no consideration of distance or occlusion (An object in front of the entity blocking the view). You'll have to decide how to handle that yourself.

@TorakWolf
Copy link
Author

So, I transform whatever angle information it is on degrees, then use tangent that for every x position, for example, the z must be x times the tangent of the angle between the distance ray and the x distance, then if isLookingAtBlock == false, the nearest mob that matches the x and z conditions is choosen as the target.

@nevercast
Copy link
Member

I think that would work yes :)

@nevercast
Copy link
Member

I'm guessing you worked this out, @TorakWolf
I'm going to leave this issue open as a reminder to consider implementing this in the future.

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

No branches or pull requests

3 participants