|
Hello, I am using this script and the object I apply this script to floats in the air as it attempts to follow my character. How can I get the object to remain on the terrain as it follows my character? (the character changes heights on the terrain) Thank you.
(comments are locked)
|
|
I had the exact same problem sometime ago, here is the solution: The object is floating in the air because it is following the center pivot of your character (which is probably higher than your follower), if you want it to stay on the ground, just create an empty gameObject put it at the height of your character follower, but close to your character and attach it to him, add a tag to it (like targetPoint) and instead of looking for the player, look for that point: Hope it Helps :) This would work if my player was moving at a constant height, but it is varying. Thank you for the response.
Oct 12 '12 at 03:44 AM
sjj100
(comments are locked)
|
|
Easiest way is, you can make a raycast from your object to Vector3.down so you can find the point to snap on each frame. Edit: I have not test it but possibly similar solution like this: Edit2 : I have changed the code. i rewrite it for java script. it would still give some possible errors, notify me further ;) I seem to be encountering some compile errors with NowhereStudio's answer... (24,15) ';' expected. Insert semicolon at the end. (25,10) ';' expected. Insert semicolon at the end.
Oct 12 '12 at 03:55 AM
sjj100
try to add only "edit done here" written block to your previous not error giving update function
Oct 13 '12 at 09:53 PM
NowhereStudios
aha i found i guess you are not using csharp i edited the post above
Oct 13 '12 at 09:54 PM
NowhereStudios
(comments are locked)
|
