Don't know what I should use for the origin and direction

Okay so I’m basically trying to make a tree chopping system similar to animal crossing, where the tree shakes and can drop items when you chop it.

However, since I am using raycasting to detect if the tree has been chopped, I don’t know what I should use for the origin and direction. At the current moment, I am using the player’s mouse. But, I want this game to have mobile support. What else should I use?

I have tried using HRP.LookVector * agrodistance, but that requires the player to be directly staring at the tree, and I just want it in the general area where the player can hit it.

This is the raycast function:

Sorry if this post isn’t in the right topic, as this is my first post :sweat_smile:
Any help will be appreciated :cowboy_hat_face:

You could combine this

TouchTap which gets the position the user tapped on the screen. And pass that position in to the players camera:ScreenPointToRay()

Which should give you the ray you’re looking for.

I guess maybe you don’t mean for them to tap. In which case you could fire from the center of the screen or you could do a spatial query for all parts near the player and check if there is a tree and that it’s in the general direction you want.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.