How do I assign a direction for a ray?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a bottle that spills water after being thrown and hitting something.

  2. What is the issue? Include screenshots / videos if possible!
    I dont want the water to be at the position where the bottle hit something, I want it to hit the ground right below it. Example: A water bomb is thrown and it hits a wall. I dont want the water to be floating on the wall. I want it to be at the ground below it. I dont know how to do a raycast like this. What if the bottle is oriented? Will the ray’s direction be the Y axis of the bottle or the world’s Y axis. I want the ray to go down regardless the orientation of the bottle.

I dont know how to properly set a ray’s direction. Please explain in an easy manner. I am a very noob dev and cant understand the language of higher beings.

1 Like

If you set the raycast from the world position of the bottle not the cframe position than you are able to get a straight raycast down to the ground for example:

pos1 = bottle.Position  -- 'bottle' would be the bottle instance
pos2 = pos1 - Vector3.new(0, -20, 0)  -- we are subtracting 20 of the y value of the position to get a position lower than the first point
local raycastResult = workspace:Raycast(pos1, pos2)  -- Send out raycast
2 Likes

I am going to test this. Thank you for the reply!

Sorry for asking but how do I get a parts world position? Is it the same as “Position”?

Yes it is “World position” is just another saying for the parts .position property

1 Like

Thank you for the help! I am grateful for your help! Now I can make the water bottle.

1 Like