How do I Make my object go in direction of swing

Get help using Construct 2

Post » Tue Nov 03, 2015 10:37 am

Hello,
So at the moment I have this game where its all about swinging around.
I can swing 360 degrees around the object you click on, when you let go I want my character to fly off in the direction when you let go.

Thanks in advance :-)
Last edited by Revilo on Thu Nov 05, 2015 12:10 pm, edited 2 times in total.
B
5
S
1
Posts: 37
Reputation: 463

Post » Tue Nov 03, 2015 10:51 am

Without knowing the behaviours and setup you use for player-movement and swinging around, it might be hard to answer this question..

There must be something within your game you can get the current angle from on release and set the movement direction of the player to at that time..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Nov 03, 2015 11:09 am

This is how I'm making my character swing:
On left button down, every tick.
Character, Set position to (Object.x+cos(time*speed)*radius, (Object.y+sin(time*speed)*Radius)
This works well for me, a part from the fact when i click on the object to make my character swing it puts him however far from the block due to my radius being a set number.
Hope this helps
B
5
S
1
Posts: 37
Reputation: 463

Post » Tue Nov 03, 2015 11:36 am

you could use the oldx, oldy method ..

player is not swinging set angle to angle(oldx,oldy,player.x,player.y)

every tick set oldx to player.x, set oldy to player.y
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Nov 03, 2015 11:51 am

"a part from the fact when i click on the object to make my character swing it puts him however far from the block due to my radius being a set number." If I understand this then part of your problem is finding the distance from the object clicked to the player and setting the radius to this distance? If this is the case all you need to do is

radius = distance (object.x, object.Y, player.X, player.Y).
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,832

Post » Tue Nov 03, 2015 12:02 pm

Thank you very much ram, that works perfectly. :)
B
5
S
1
Posts: 37
Reputation: 463

Post » Thu Nov 05, 2015 12:12 pm

Little stain this isnt working...
B
5
S
1
Posts: 37
Reputation: 463

Post » Thu Nov 05, 2015 12:18 pm

A bit more explanation other than it isn't working would be nice..

What isn't working?
What are the events and attached actions?
What did you expect to happen and what does happen?
Are there any conflicting events?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish and 15 guests