[SOLVED]How do I click the mouse to move the character?

How to click on a position on the screen with the mouse, and the character can be operated to reach the clicked position?

For a straight line without obstacles you can use the tween behavior. To navigate around obstacles, you can use the path finder behavior with the pathfinder obstacle behavior on the obstacles. If you just want to move towards that point you can use forces.


I would create two variables
DesX DesY
As in destination

And when i click somewhere on screen i would save CursoX() to DesX
And CursroY() to DesY

Now i would have another event where i would go with add force to player toward position Variable(DesX) Variable(DesY)

And add condition

This way player would go there only if its distance from that point is not higher than 3
So he would auto stop
And each new click would generate new DesX and DesY

Thank you very much for your method, I realised the displacement, but ran into a new problem!
I want a correct path and how can I do it:

Thank you very much!

Thank you very much for your method, I implemented the displacement but ran into a new problem! However, I’m not very familiar with f(x) and this is my exact step, I’m not sure if it’s correct or not:

This is my rendering.:
In real time, I was in need of such a path:

How can I achieve this accurately, thank you for your help!

I am very bad with pathfinding

BUT from what i understand if that gray blocks are obstacles
Then your player object can’t be bigger than path it can take

ANd by NOT BIGGER i mean there was option to set bounds or something like to determine in pathfinding size of collision of your object

But beyond that i have no idea

Thank you very much for your reply, grey blocks are not obstacles, they are something like steps to jump up. The character has a gravity and stands on the steps. I’m working on fixing this though, thanks for the reply, much appreciated! :grinning:

You could tween the x and the y seperately.

The issue with tween is it’s based on time not speed. So, if you use a fixed time it would move faster to go further and slow to go a short distance. This uses the cursor.

If the player or AI is choosing those lines or platfroms then you could replace the cursor with the playform. This uses the cursor to pick a platform and a variable to prevent the move from being changed. If the objects have platfrom behavior then you would need to disable the platform behavior on the player.

I just realized that if it was a platform then you could simulate platform keys and jumps. While simulating left and right would be easy jumping up or between platfroms would be more difficult.

Thank you very much Keith_1357,
I followed your method and finally tried to use the analogue jump button to achieve the effect I wanted, however, I encountered another problem, how can I make him just jump to the platform above and then stand still for my next operation, now, he always jumps non-stop!

add “trigger once” to “has finished playing” event

A trigger once would work but I would use a remove the tween to the has finished playing.

Thanks Modo, I think I’ve solved the problem at this stage, thanks! :smile:

Thanks Keith_1357, I think I solved the problem at this stage, thanks! :+1:

1 Like