Hello,
I am still working on my piano bar room and unfortunately i am stuck again.
I want the character to be able to sit on a chair and just listening to the pianist with a idle view
view 167= the character sitting on the chair
function ochair_Interact()
{
cChar1.Walk(1420, 820, eBlock);
cChar1.FaceDirection(eDirectionUp);
cChar1.LockView(167);
}
I had this code but i think the lockwiew was preventing the idle view to animate so i made a timer that triggers the idle view.
function ochair_Interact()
{
cChar1.Walk(1420, 820, eBlock);
cChar1.FaceDirection(eDirectionUp);
SetTimer(7,80 + Random(500));
cChar1.LockView(167);
}
function room_RepExec()
{
if (IsTimerExpired(7))
{
cChar1.Animate(0, 5, 0, eBlock, eForwards);
SetTimer(7,80 + Random(500));
}
}
It works well maybe there was an esier way to do this ?
Now i want that when the player click somewhere it makes the character stand up and go back to the normal view
I don't know how to do that i had a look at: "on mouse click" but i am not doing anything good i tried that:
on_mouse_click
{
cChar1.UnlockView();
cChar1.LockView(1)
}
It gives me an error and i don't really know where to put it
Thanks again for your precious help.
You need to put this in the room script:
function on_mouse_click(MouseButton button)
{
if (button == eMouseLeft && cChar1.View == 167) // using the view's name is preferable
{
ClaimEvent(); // don't run global on_mouse_click after this
cChar1.UnlockView();
}
}
Note that AGS supports idle views, and more importantly: do not lock the view to view 1, unlocking it is enough to return to default behavior.
You lock the view to perform a specific animation, then unlock when the animation is done.
Hello,
I am so sorry it took me so long to answer.
I used your script and it's perfectly working so now i know how to do it (a click + a condition) and it's going to be really useful.
Thanks also for the explanation about unlocking views.
Once again thanks a lot for your precious help.