- Home /
gravity or others. i don't get it. what i suppose to coding it
i have a problem on the interface of this game. example, i have a box. i have done to give a character control for it. so in the map i have a hill. and when my character go up to the hill. the character didn't touch the ground well.
difficult to explain it ok this is the pict.
left pict is my character looking. and the right pict is my imagination character looking. what i have to learn about. it is about gravity? or other? somebody please give me your advices
You have to use rigidbody ins$$anonymous$$d of a characterController
rigibody,,, ok oh yeah can you please give me a script that is having a similarity with this case?
the left picture is correct if you don't want to move your character with physics witch is most recommended
while you'll found lots of problems in the right picture making your sphere in the end or capsule
you won't be able to go up hills
if capsule you if you go up hill you'll figure out that your head is going to knock back on the floor
i want to make a character from the "box" shape so i don't think about make it to be a capsule. oh yeah about "correct if you don't want to move your character with physics" what kind of physics i must take to the character? can you give me a sample script please,,, :) i need your help so much about it because i am a new for it
Answer by whydoidoit · Jan 19, 2013 at 12:32 PM
If you want to orient your character to stand on the surface of the item it hits you can do that using a ray cast:
RaycastHit hit;
if(Physics.Raycast(transform.position, transform.down, out hit, 2)) //Change 2 to fit just more than the height of your character
{
transform.rotation = Quaternion.FromToRotation(transform.up, hit.normal)
* transform.rotation;
}
wow thank you :) i will try it ok i say again, thank you very much :)
oh ya can i ask you something,,, can you explain to me what is ray cast?
Your answer
Follow this Question
Related Questions
haw to fix the roteid ground for the chareter ? 1 Answer
Character controller model colliding. How to disable it? 1 Answer
Character Controller/Motor Ground Delta 0 Answers
character gravity problem 1 Answer
Gravity not working 1 Answer