|
(Player Object is Using the CharacterController component) This seems like the best way (unless you can do it vectors). I want it to where depending on what type of surface you're on, particles emit to indicate it. (i.e: dust if your on a dirt terrain, grass if on a grass terrain) and to play a sound for the corresponding textures while there verticalDirection > 0. I figured since I can't use triggers or colliders for this, I should use raycasting. However, I'm a complete novice to raycasting and don't know how I could execute this. I was also wondering if it would be possible to check the texture of the object I'm standing on in case on object that has multiple textures. Edit: I made a script based on lhk's answer, but I'm getting a error: Unknown Identifier: "origin". Here is the code:
(comments are locked)
|
|
The reference says:
As you can see you call Physics.Raycast() with the origin and the direction as parameters. A RaycastHit object, the distance/length of the ray and a layer are optional parameters. Physics.Raycast() returns true, if something was hit. To sum up you need to
RaycastHit contains
By using
You may access the gameObject the ray has hit. Then you can check wether it is tagged "surface" or something like that. Moreover the hitinfo offers you the desired Texture coordinates.
(comments are locked)
|
|
There is no variable named origin in your script. Nevertheless you try to access it in the call ti Physics.Raycast. You could add another line to the Update function, before Physics.Raycast
Note that I'm substracting another Vector of your position. This is meant to avoid intersection from the Ray with the player itself. I don't know wether this is necessary.
(comments are locked)
|
|
Thank you, Thank you and once more I thank you. This is what I have been searching for for days.
(comments are locked)
|
