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

I would like to leave a bullet hole there when my custom projectile hits a block. I can get BlockHitResult with Projectile#onHitBlock,

1. What should I use to render bullet holes? particle? But it points towards the player's camera. Should I create a bullet hole class, save it to a Map and render it directly?

2. No matter how I render, I need data of the angle of the hit surface and its angle. How do I get this?

3. When the bullet hits a block such as a stone, I would like to reflect it instead. After getting the angle of the surface in 2, how do I calculate the reflected vector from it and the delta movement of the bullet?

Please let me know if you have any hints for any of 1, 2 or 3.

 

For reference, my code is here .

Hi,

so I have no idea how rendering works, but I can help you with 3.

 

You first need to know, that if a ray hits something, it will reflect with the negative angle. So if you have a plane and 0 degrees are exactly a line towards the plane and you shoot a ray with -30 degrees (so a little bit from the left towards the center of the plane) it will reflect with 30 degrees, if you shoot a ray from 0 degrees (so exactly towards the plane) it will reflect with -0 (the same as 0) degrees, if you shoot a ray 70 degrees (so from very right to the middle of the plane) it will reflect with -70 (so to the left)

 

But now you have a cube and not a plane. If you shoot a ray towards one side of a cube the angle could be 0, 90, 180 or 270 degrees. What you need to do is get the side the arrow hits the block and then subtract 0, 90, 180 or 270 degrees. I'm not sure, but I think north you don't need to subtract (so basically 0). The other sides you need to try. Then, if you have subtracted, you negate the value (this is this -70 to 70, 50 to -50) and add it twice to the rotation of the arrow (not the subtracted). This is your end rotation it will reflect from.

 

This was everything for a 2D environment, but I think if you know this, you can do the same in a 3D environment like Minecraft

 

Wow, that was very much

Edited by OutCraft
Spelling

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

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.