mouse click movement Forum Home > Construct 2 General > How do I....? |
Post Reply
|
Page 123 4> |
| Author | |||
Post Options
Quote Reply
Topic: mouse click movementPosted: 15 Sep 2011 at 9:11pm |
|||
|
I'm trying to figure out what the best way is to let my player sprite move to where the Mouse is.
What would be really helpful is a behaviour that will allow me to set the player movement speed as well as letting him move to the current mouse.x and mouse.y I know there must be a way, I am just too noob to figure it out it seems. If I set it to current mouse X or Y with position it jumps there instead of moving towards it. I have coded something klike this before saying: X = X++1 until the mouse is let go but how do I set it in C2? I suppose I could use 'On Every Tick' but that seems kinda wasteful? How possible will it be to also restrict the Y movement? So lets say I click on a co ordinate the player will move towards the x co-ordinate (left and right only) and not move up or down at all? There must be a way but I would maybe think that it's such a common control interface in multiple games that it will have a behaviour dedicated to this kind of movement. Edited by Havok - 15 Sep 2011 at 9:18pm |
|||
![]() |
|||
Post Options
Quote Reply
Posted: 15 Sep 2011 at 9:57pm |
|||
|
Have a look at this, it might be useful to what you're tying to do, it's a pathfinding example:
http://www.scirra.com/forum/behaviorpathfinder_topic44444_page1.html |
|||
![]() |
|||
Post Options
Quote Reply
Posted: 15 Sep 2011 at 10:24pm |
|||
|
You can still do
Edited by shinkan - 15 Sep 2011 at 10:26pm |
|||
![]() |
|||
Post Options
Quote Reply
Posted: 15 Sep 2011 at 10:34pm |
|||
|
PathFinder has no automated movement. 8dir has, sort of.
Automated Movement.capx To restrict Y movement in this cap simply disable the conditions testing Y. Also "such a common control interface" relies so much on what the dev wants (expect for his gameplay), that for it to be fully customizable, it is better if the dev does it himself. (Or also what Shinkan said, ninja'd) Edited by Kyatric - 15 Sep 2011 at 10:36pm |
|||
![]() |
|||
Post Options
Quote Reply
Posted: 15 Sep 2011 at 10:37pm |
|||
|
8dir following a mouse looks kind of odd.
|
|||
![]() |
|||
Post Options
Quote Reply
Posted: 15 Sep 2011 at 10:44pm |
|||
|
You can always set the 8dir behavior's angle in the properties to no.
It doesn't rotate and probably will look less odd to you. |
|||
![]() |
|||
Post Options
Quote Reply
Posted: 15 Sep 2011 at 10:51pm |
|||
|
The rotating is cool. It points in the direction it's moving.
|
|||
![]() |
|||
Post Options
Quote Reply
Posted: 16 Sep 2011 at 12:08am |
|||
|
You could just give the object a bullet movement and always set its angle to face the mouse.
|
|||
![]() |
|||
Post Options
Quote Reply
Posted: 16 Sep 2011 at 8:14am |
|||
|
Thanks for the help so far guys.
Kyatric that's almost there I reckon. It's just the "shaking" that's not ideal. I'll have to try edit it a bit more. Thanks a lot for this. Ashley, I'll try the Bullet behavior as well. I think Construct 2 could use a behavior that simplifies this. I am trying to use Construct 2 as a type of point and click adventure game. Having behaviors that helps in this area would be a huge boon to me and I'm sure many others. |
|||
![]() |
|||
Post Options
Quote Reply
Posted: 16 Sep 2011 at 2:46pm |
|||
|
The bullet behavior only needs one event to get it to always move to the mouse (always - set angle to Mouse.X, Mouse.Y). Does that really justify a whole new behavior?
|
|||
![]() |
|||
Post Reply
|
Page 123 4> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |