#how do i make a cube raycast to a trigger

47 messages · Page 1 of 1 (latest)

twin notch
#

Trigger Position - Cube Position = Direction of Cube to Trigger

twin notch
#

Can’t send a picture sorry

#

But use Get Position on the trigger handle

#

And use Rec Room Object Get First With Tag to get the cube(use whatever tag you used on the cube) then use Get Position on the cube

#

Then wire both positions into a Subtract

#

Order matters though, make sure the trigger handles position goes first

vale saffron
#

Yes

twin notch
#

Connect it to the Direction port on the raycast

#

Yes

vale saffron
#

Why do you see through...

#

But raycast are invisible

#

If you want a ray use "rangefinder"

twin notch
#

Why are all your ports blue

vague fable
#

damn what my message never went through!

#

No these methods are all bad @vale saffron @vale saffron @twin notch

#

it was such a good method

twin notch
vague fable
#

Alright lemme retype this real quick, I sent it on school wifi lol

vague fable
#

Have 2 objects

  • Laser Pointer
  • Cube

Tag the cube with LaserCube and lc0 (0 is index)
Tag the laser pointer with LaserPointer and lp0 (attached cube index)

For each laser emitter:

If the laser is enabled,

Then, Start a custom while loop with 3 variables, Current Position, Current Direction, Hit Object

When the loop is started, set Current Position and Current direction to laser emitter position/direction

On loop, cast a ray in the direction of current position, in the direction of current direction with a length of infinity

Check if the raycast hits an object with Is Valid and that it has the tag LaserCube

If both are true, enable the laser cubes laser via the laser cubes index

If any are false, stop the loop
You can also check if the object it hits has the tag LaserCatcher in order to activate something

#

Basically, this way the laser will continue indefinitely until it reaches the end

#

Exactly like the portal 2 laser

#

I do now see an issue with this of, how to detect if nothing is hitting it, if it disconnects

#

hmm...

#

I think this would be a forward/backward thing

#

For each cube hit, tell the cube the inverse of direction and hit position and distance
Now, cast backwards, if it doesnt hit anything emitting a laser, turn off laser

#

You could also probably solve this with a string/list

#

Basically say the list is 0,1,2,3,4,5, which means it hits 5 cubes

If 2 stops hitting 3, remove everything after 3

vale saffron
#

@vague fable i just said use a range finder for the laser how is my method bad what 💀

vale saffron
#

What's that

vague fable
vale saffron
#

Oh

#

Didn't know

vague fable
#

I just realised how expensive that would be

vale saffron
#

Mb

vague fable
#

because they dont have collision by default, or at all

#

meaning you need to make custom collision for them

#

for each cube.

#

this method requires 3 loops holy shit

  • Activation While Loop
  • For Each laser disable if not being hit loop
  • Laser collision distance loop
#

I mean Laser Pointer, it doesnt have collision, you need to set its distance to a raycast

#

I know putting physical objects inside animation gizmo gives you portal style cube physics

#

Just make sure if players pick up cubes with their gun and not their hand, you avoid prop-fly

#

create them, search Variable

#

or, if its an event, configure the event definition

#

3 types
Vector3 to record position of last loop
Vector3 to record direction of last loop
Rec Room Object to record the object hit

vague fable
#

When you execute it, it stores the input value