Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- laser = Besiege.GetBlock("LASER 1")
- water_cannon = Besiege.GetBlock("WATER CANNON 1")
- water_cannon.SetToggleMode("HOLD TO SHOOT", True)
- def Update():
- # we use laser position as origin of the raycast and add forward vector for offset to avoid raycasting laser block body
- origin = laser.Position + laser.Forward
- # we use laser forward direction vector as raycast direction
- direction = laser.Forward
- try: # raycasting raises exception if it doesn't hit anything
- hit = Besiege.GetRaycastHit(origin, direction) # point of the raycast hit
- distance = (hit - origin).magnitude # calcuate distance from origin to hit position
- water_cannon.SetSliderValue("POWER", distance / 10.0)
- water_cannon.Shoot()
- except:
- pass # do nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement