Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello guys,

I've just made a new mob and I'd like to check if there's any other mob in front of it. If NOT my mob should throw an arrow, otherwise it shouldn't do that (so it shouldn't damage its "allies"). I'm actually creating an invisible entity for this which collides with any possible mob and check if my mob can shoot, but it wastes a lot of useful memory and packets. Is there any other way for doing that? Like for ex. a ray tracing way (I don't know what should I look for in order to learn about ray tracing)?

 

Thanks and have a good day/night,

Axel

Hi

 

I'd suggest:

(1) search for entities nearby.  Discard any which are not nearby.

(2) For each nearby entity, check whether its bounding box is intersected by the line of fire of the arrow (i.e. the bounding box has four vertical edges: if they are all to the left of your line of fire, or all to the right, then the arrow will miss.  Otherwise it may hit.

(3) optional: ray trace from the target entity to your mob, to see if there are any blocks in the way which would shield the entity from the arrow.

 

I probably wouldn't bother with the ray trace myself, I suspect that in most cases it wouldn't actually make any difference and it's likely to be rather expensive to compute.

 

Figuring out "left or right" requires a bit of vector math, not too hard if you've studied math, but let us know if you need a pointer in the right direction.

 

Alternatively - you could just make your mob immune to its own arrows.  Would be an awful lot easier.

 

-TGG

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.