Rotate circle on mouse position
4 posts • Page 1 of 1
Rotate circle on mouse position
Got an idea to make a battleship with working guns and stuff. The only problem is that I can't understand completely what's going on in the automated mouse-controlled gun (the one made by pixartist). And I just want to activate the axle without changing the RPM.
Help will be helpful
EDIT - This is the thing which I want.
Help will be helpful
EDIT - This is the thing which I want.
- Attachments
-
- Capture.PNG
- (28.46 KiB) Not downloaded yet
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- Luka
- Posts: 17
- Joined: Wed Oct 23, 2013 12:57 pm
- Location: pos[0, 0]
Re: Rotate circle on mouse position
Simplest way is to set bend / bendTarget for turrel and connect it to +inf inertiaMultilpier circle.
Draw new circle on top of turret, hinge it to turret.
in circle ->
postStep = (e) => {scene.my.tpos = pos}
onSpawn = (e) => {scene.my.tpos = pos}
inertiaMultilpier = +inf
in bend hinge ->
bend = true;
bendTraget = {v := app.mousepos - scene.my.tpos; math.atan2(v(0),v(1))}
Draw new circle on top of turret, hinge it to turret.
in circle ->
postStep = (e) => {scene.my.tpos = pos}
onSpawn = (e) => {scene.my.tpos = pos}
inertiaMultilpier = +inf
in bend hinge ->
bend = true;
bendTraget = {v := app.mousepos - scene.my.tpos; math.atan2(v(0),v(1))}
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Rotate circle on mouse position
Worked. By the way the bendTarget was offset.
So I changed the atan2 part code and swapped 0 with 1 and 1 with 0 (that's how math calculates angle from 2 variables).
So I changed the atan2 part code and swapped 0 with 1 and 1 with 0 (that's how math calculates angle from 2 variables).
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- Luka
- Posts: 17
- Joined: Wed Oct 23, 2013 12:57 pm
- Location: pos[0, 0]
4 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 10 guests