Mouse controlled AIMing point.

Get help using Construct 2

Post » Mon Jun 10, 2013 3:26 pm

Hello !

i'm working on a top down shooter type "hotline miami"

the character is moved by the arrows,
and he can aim and shoot with the mouse.


actually i use this :


bullet > set angle toward (mouse.x, mouse.y)

it works, BUT .

when the mouse is really near my character, things become buggy.
and when the mouse is very far from the charachter , you have a long way back if you want to turn around.

what i would like to do :

the aiming point is controled by the mouse, but its not the mouse.

the aiming point follow the direction of the mouse , but is bounded in a circle which the center is the character.

the aiming point is always on this circle at 300 pixel (for example) of the character.     never closer and never far away .

so the mouvement you need to do to have a specific reaction will always be the same, despite the real position of the mouse.


i tried to be clear, dont know if you can understand what i mean.
if someone can help, it would be apprecied !


thanks !







B
19
S
5
Posts: 104
Reputation: 1,761

Post » Mon Jun 10, 2013 3:28 pm

You could try giving your character Turret behavior, and have its target be a sprite that's restricted within the circle you want but mouse-controlled.. That will have him/her rotate at a predefined rate towards the mouse, no matter where the mouse is or how fast it's going.

The last thing I'm not sure how to do, good luck!ChrisAlgoo2013-06-10 15:30:23
B
17
S
4
G
4
Posts: 143
Reputation: 4,004

Post » Mon Jun 10, 2013 4:18 pm

Look at the Diablo style movement example. It could probably easily be modified for shooting.

Capx: http://dl.dropbox.com/u/23551572/C2/diabloLikeMov.capx
Wigriff2013-06-10 16:19:46
B
6
S
1
Posts: 62
Reputation: 532

Post » Mon Jun 10, 2013 4:21 pm

dont set angle of the bullet, just set the top down shooter direction every tick to mouse x mouse y, the bullet will shot towards the direction of the mouse.
B
4
Posts: 10
Reputation: 220

Post » Mon Jun 10, 2013 5:17 pm

@ice : i cant because the bullet is spawned by the weapon, which is not at the center of the character sprite, so if i do that the bullet dont reach the target , there is the same offset a the arriving that there is a the departure.

@chrisalgoo : i didnt experiment the turret behavior yet. i'm going to test that. but i dont think it will do

@wigriff : i checking that right now !

thanks all.
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Mon Jun 10, 2013 5:39 pm

no i dont think i can use this wigriff.   
maybe i wasnt enough clear.

basically i think the mouse should only pilot the aiming

imagine a circle of 200 pixel with the character in the center.
if i go 200 pixel left, my aiming is at the maximum left,
i go 200 pixel right the aiming go to the maximum right,
then i go 200 pixel left, then again 800 pixel left,
the mouse is now 1000 pixel away from the center, but if i move 200 pixel right, the aiming still go to maximum right.


so even if my character is in the center and the mouse in the upper left corner, i can piloy my character the same way as if the mouse was in the center.

and when my mouse is between the character and the circle, the aiming point stay always on the ring.

am i more clear ?

in fact i think we need to forgot the position of the mouse.
what is important is in which direction the mouse is moving.
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Mon Jun 10, 2013 5:56 pm

Example capx using the pin behavior.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
291
S
114
G
95
Posts: 7,290
Reputation: 70,138

Post » Tue Jun 11, 2013 10:01 am

@kyatric !

wonderful ! that will do perfectly.
the problem when the mouse is too close of the hero is now solved !

that was the main thing so : thank you very much !
manukeo2013-06-11 10:03:25
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Tue Jun 11, 2013 7:08 pm

@kyatric

in fact, that was interesting but not definetly good.

...

im checking the math formula and expression all deay, but still dont know how to do it.

basically : center of "player" is point "A"   ans mouse is point "B"

i need to obtain the line between A and B and display my "aim" on this line, at 150 pixel distance from point A .

know how to do that ?
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Tue Jun 11, 2013 7:18 pm

no no. my mistake. i will have the same problem with that when my mouse will be between the aim and the player.

need to think about it again .

B
19
S
5
Posts: 104
Reputation: 1,761

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 31 guests