Jump to content

Phaser - Smart point & click character movement that can consider collisions

Recommended Posts

Hey Phaser people,

I'm currently working on a 2d upperview point & click game, using Arcade physics.

What I want to develop is a "smart movement" system, where if you click on a part of the map, your character shouldn't get stuck in obstacles, but pass around them. 

For now, I'm using tweens to move my character to the mouse position, which cancels the collision. Thus, it's a no go.

            this.game.input.onDown.add(this.movePlayer, this);

            movePlayer: function (pointer) {
                var time = 9.5;
                var duration = (this.distance(this.player.x, this.player.y, pointer.x, pointer.y) * time);
                this.tween = this.game.add.tween(this.player).to({ x: pointer.x, y: pointer.y }, duration, Phaser.Easing.Linear.None, true);

Any suggestions ? Thanks ! I've also attached a small screenshot/ drawing of what I strive to achieve.


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...