Pupils follow mouse cursor/character (solved)

Started by Amir, Mon 02/08/2021 17:59:38

Previous topic - Next topic

Amir

Hi,

As you can see in some games, most of the time at the menu on the background image. The pupils follow the mouse cursor.
I made a walkable area in the eyes 2 circles then made something little transparent and pupils as characters. I tried to do something like this:

In the room c.Fakemouse.Transparency = 100;

and

Code: ags

function repeatedly_execute()
{
cEyes.FollowCharacter(cFakemouse, 1, 1);
cFakemouse.x = mouse.x;
cFakemouse.y= mouse.y;
}


It's not so bad but the problem is that the pupils move sometimes constantly because they want to follow the mouse cursor and cannot leave the walkable area. for example, when the cursor is in the lower center, the pupils go down but move right and left all the time, as I said because they want to get out. I don't really like it that much.

Another thought: views of animating pupils and depending on the position of the mouse cursor x and y. But the movement of the pupils will look terrible.
Does anyone have a smarter idea?

I would like to do the same thing too, so that character's eyes follow the main character when he walks past. I think that would be the same technique. But pupils follow the mouse cursor is more important to me.
Truly, truly, I say to you, blessed are those who play adventure games, for theirs is the kingdom of heaven.

Cassiebsg

FollowCharacter will always make it "fudgy".

Just get the mouse the mouse coordinates, and then update the pupil by moving them instead.
There are those who believe that life here began out there...

Cassiebsg

FollowCharacter will always make it "fudgy".

Just get the mouse coordinates, and then update the pupil by moving (or just update the x,y) instead.
There are those who believe that life here began out there...

Amir

Quote from: Cassiebsg on Tue 03/08/2021 16:52:52
FollowCharacter will always make it "fudgy".

Just get the mouse coordinates, and then update the pupil by moving (or just update the x,y) instead.

But the pupils would go out and not stay in the eyes, that's why I had to use FollowCharacter and walkable area in the eyes.
Truly, truly, I say to you, blessed are those who play adventure games, for theirs is the kingdom of heaven.

Cassiebsg

Just don't provide x,y that is inside the the eyes/walkable area. Or use walk, results in the same anyway just make sure it's not set to anywhere.  ;)
There are those who believe that life here began out there...

Amir

If I use walk you will have to click first to make the pupils move and I don't want it like that.

QuoteJust don't provide x,y that is inside the the eyes/walkable area.

Hmmmm ok I will try.


Truly, truly, I say to you, blessed are those who play adventure games, for theirs is the kingdom of heaven.

Cassiebsg

#6
Correction: Just don't provide x,y that is inOUTside the eyes/walkable area.  (roll)
This is what happens when I change a sentence in my mind halfway of writing it.  (laugh)

Also, you don't need to click anywhere, the pupils will only move when the mouse moves, and if they're already where they're suppose to be looking, then they'll just stay there. You aren't processing the clicks, you are moving the character your self to the designated x,y, and the character will try to move there, if it can (but since you've limited it to a walking area, it's trapped as long as you don't use eAnywhere).
The only difference between using walk and move, is that walk will play the walk animation (if there's more that 2 frames) and move won't.
There are those who believe that life here began out there...

Khris

Use math to move the eyes instead.

Code: ags
  cEyes.x = eyes_center_x + (mouse.x - eyes_center_x) / 100;
  cEyes.y = eyes_center_y + (mouse.y - eyes_center_y) / 100;


https://de.wikipedia.org/wiki/Strahlensatz ;)

Amir

@Khris - I would love to give you a Nobel Prize for this idea. It works like a charm, thank u. I just had to change /100 to /40 for x and /20 for y to give the pupils a little more space.

@Cassiebsg - Thank u too for ur suggestions and help. I will try it anyway, even though I will leave the math solution in my script.
Truly, truly, I say to you, blessed are those who play adventure games, for theirs is the kingdom of heaven.

SMF spam blocked by CleanTalk