Interesting! I would have never thought of using greater than/less than as a math expression to determine the animation. Thank you very much for the suggestion! It does seem like this still creates a blocking walk, so you can't turn mid movement.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menufunction DetermineCharacterAngle(Character *c)
{
if (c.GetProperty("TargetX") < c.x && c.GetProperty("TargetY") > c.y) { //down left
c.SetProperty("CharacterAnim", 1);
}
else if (c.GetProperty("TargetX") > c.x && c.GetProperty("TargetY") > c.y) { //down right
c.SetProperty("CharacterAnim", 0);
}
else if (c.GetProperty("TargetX") < c.x && c.GetProperty("TargetY") < c.y) { //up left
c.SetProperty("CharacterAnim", 3);
}
else if (c.GetProperty("TargetX") > c.x && c.GetProperty("TargetY") < c.y) { //up right
c.SetProperty("CharacterAnim", 2);
}
//orthogonal direction handling
else if (c.GetProperty("TargetX") == c.x && c.GetProperty("TargetY") > c.y) { //down
if (c.GetProperty("CharacterAnim") == 0 || c.GetProperty("CharacterAnim") == 2) {
c.SetProperty("CharacterAnim", 0);
}
else {
c.SetProperty("CharacterAnim", 1);
}
}
else if (c.GetProperty("TargetX") == c.x && c.GetProperty("TargetY") < c.y) { //up
if (c.GetProperty("CharacterAnim") == 0 || c.GetProperty("CharacterAnim") == 2) {
c.SetProperty("CharacterAnim", 2);
}
else {
c.SetProperty("CharacterAnim", 3);
}
}
else if (c.GetProperty("TargetX") < c.x && c.GetProperty("TargetY") == c.y) { //left
if (c.GetProperty("CharacterAnim") == 0 || c.GetProperty("CharacterAnim") == 1) {
c.SetProperty("CharacterAnim", 1);
}
else {
c.SetProperty("CharacterAnim", 3);
}
}
else if (c.GetProperty("TargetX") > c.x && c.GetProperty("TargetY") == c.y) { //right
if (c.GetProperty("CharacterAnim") == 0 || c.GetProperty("CharacterAnim") == 1) {
c.SetProperty("CharacterAnim", 0);
}
else {
c.SetProperty("CharacterAnim", 2);
}
}
}
function MovePlayerToMouse()
{
cRoger.SetProperty("TargetX", mouse.x);
cRoger.SetProperty("TargetY", mouse.y);
DetermineCharacterAngle(cRoger);
cRoger.Animate(cRoger.GetProperty("CharacterAnim"), 1, eRepeat, eNoBlock);
cRoger.Move(cRoger.GetProperty("TargetX"), cRoger.GetProperty("TargetY"));
while (cRoger.Moving) {
Wait(1);
}
cRoger.ChangeView(cRoger.View);
}
Quote from: eri0o on Sun 28/04/2024 03:06:43What is the intended movement control scheme? Is it by mouse or keyboard button?Both, which I've got set up. I'd also like characters that the player does not control to animate this way, too.
Quote from: Snarky on Sat 27/04/2024 23:10:18Then you would call that function when you make a character walk. For example, if you walk by clicking, you would probably call it in on_mouse_click().I've put together a block of code, but it seems like putting anything in on_mouse_click() nullifies the movement-- I'm only getting the animation.
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.082 seconds with 15 queries.