#Bouncing Snowballs - Wont bounce off slabs

1 messages · Page 1 of 1 (latest)

obsidian dock
#

Please format the code

livid grotto
#

and uhhh how do i do that?

#

'''test'''

#

't'

#

''t''

serene gate
#

use triple of that

#

```
code
```

livid grotto
#
    make player shoot snowball at velocity 1
    set {_proj} to the shot projectile
    set {_item} to a snowball
    {_proj}.setItem({_item})
    set {shooter::%{_proj}%} to player
on right click with wooden shovel:
    make player shoot snowball at velocity 0.5
    set {_proj} to the shot projectile
    set {_item} to a snowball
    {_proj}.setItem({_item})
    set {shooter::%{_proj}%} to player
on projectile hit:
    projectile is snowball
    set {_hitBlock} to event-block
    if block is sand:
        broadcast "Bunker"
        stop
    if projectile.getItem() = snowball:
        cancel event
        set {_shooter} to {shooter::%projectile%}
        if ((projectile's velocity)'s vector length) > 0.6:
            set {_pos} to (the vector from (event-block's location) to ((projectile)'s location))
            set {_absx} to abs({_pos}'s x)
            set {_absy} to abs({_pos}'s y)
            set {_absz} to abs({_pos}'s z)
            #set (projectile's velocity) to vector((projectile's velocity's x), -(projectile's velocity's y), (projectile's velocity's z))
            teleport projectile to ((event-location) ~ (normalized (projectile's velocity))*-0.2)
            
            
            if all:
                {_absx} > {_absy}
                {_absx} > {_absz}
            then:
                set ((projectile's velocity)'s x) to (-0.75 * (projectile's velocity)'s x)
                
                
            else if all:
                {_absy} > {_absx}
                {_absy} > {_absz}
            then:
                set ((projectile's velocity)'s y) to (-0.75 * (projectile's velocity)'s y)
                
                
            else: # if none of the two are the largest then the last one is. 
                set ((projectile's velocity)'s z) to (-0.75 * (projectile's velocity)'s z)
            
            
            shoot a snowball from (projectile's location) with speed 0 up
            set {_proj} to the last shot projectile
            set {_proj}'s velocity to event-projectile's velocity
            if {_shooter} is set:
                set shooter of {_proj} to {_shooter} # Reassign the shooter
                set {shooter::%{_proj}%} to {_shooter} # Update shooter tracking
            set {_item} to a snowball
            {_proj}.setItem({_item})
            
            kill event-projectile
        else:
            drop (a snowball) at ((event-location) ~ (normalized (projectile's velocity))*-0.2) without velocity
            set velocity of last dropped item to event-projectile's velocity
            kill event-projectile
            
        
on shoot:
    if projectile is snowball:
        if shooter is holding a snowball:
            cancel event```
#

first try

serene gate
#

uh huh

livid grotto
#

anyways, it just gets stuck in slabs, but if i spawn the new ball .5 blocks above the slab, it will go in a different direction

serene gate
#

is it any kind of slab or just a top or bottom slab

#

also double slabs

livid grotto
#

anything that isn't a full block

serene gate
#

alright

livid grotto
#

but on the face that isn't the full block

#

so a slab in line with a full block is fine, but not the half one

serene gate
#

also one thing i wanna point out

#
set {_hitBlock} to event-block

variable is not used once after this is set qwq

livid grotto
#

i had that set to test with

#

forgot to delete it

#

i think the velocity vector gets messed up when it interacts with non-full blocks. if i can find a way to preserve that vector right before it hits the block, then spawn it above the block, that would work great

#

but i am unsure of how to do that

serene gate
#

tested your code a bit; it bounces on the bottom of bottom slabs and on the top of top slabs (go figure)

Im not entirely sure how youd go about this but skbee has raytracing and lets you get the hit blockface of the raytrace result; maybe that could help somehow? 🤷

livid grotto
#

how so?

#

i'm not entirely sure of what a raytrace is in the first place

serene gate
#

raytrace is an invisible line from an entity or location to another location or vector (or wherever the entity is facing if youre using an entity); itll get the first thing it hits, including the blockface;
though after looking more into the issue it probably wont fix it

#

im looking more into it

obsidian dock
#

This might help

livid grotto
#

i'm a little lost in that skript, im sorry. im still fairly new

#

like how could i incorporate that into the current skript?

obsidian dock
#

If youre fairly new, no offence, you should start with something simpler and build up the skills needed for more complex stuff

livid grotto
#

im aware, but im just really tryna get this one skript down for something

livid grotto
#

I will venmo one of yall $5 if any of you can get it to work 😭