I am new to this 3D application.From the sample projects I have managed to get the source code for making an character walk.But I couldnt find any source code which will make 3D character sit.My requirement is something like this :In the world which I have created I have a chair,by clicking on the chair this model should sit and clicking it again it should stand. I will be greatful if some one has any idea.
basically you create multiple files with an animation embedded … so for eg you have you character model as file numero uno then you make copies of that model with various animated actions ie idle, attack, shield or even sitting down and standing up. Those files can be saved with original name appended with @animationName ie …
originalModel
originalModel@idle
originalModel@sittingDown
originalModel@standingUp
or even
originalModel@sittingOnLog
originalModel@sittingOnCouch
originalModel@sittingOnToilet
My requirement is that, in the mouse click event I want the character model to sit and in another click it needs to be stand up.I tried to accomplish this by below listed code
====================================
if (EventType.MouseDown==“True”)
animation.CrossFade(“sit”);
But this not excuting properly.But if I am trying to print any thing using print(“Print Something”)it is getting printed.
Any one please help me to solve this issue. That is on mouse click event an character model should sit and in another click it should stand.
You need to call CrossFade each frame. You can probably do this most easily by setting a boolean variable when the mouse is clicked. However, you should use Input.GetMouseButtonDown to test for the mouse click:-
var mouseClicked: boolean;
function Update() {
...
if (Input.GetMouseButtonDown(0)) {
mouseClicked = !mouseClicked;
}
if (mouseClicked) {
animation.CrossFade("sit");
}
...
]
This ties into this, but for NPC’s. You can have the model animation for the character to sit and stand and you have the chair model. However, how do you get the character model to sit at the place of the chair model and not to sit where there is nothing underneath him.
This would be an marker in Fallout, but I’m not sure how you would set up the script or if there is another way to do it in Unity.