The Daily Click ::. Forums ::. Klik Coding Help ::. Shooting in 360 degrees.
 

Post Reply  Post Oekaki 
 

Posted By Message

Hayo

Stone Goose

Registered
  15/08/2002
Points
  6946

Game of the Week WinnerHas Donated, Thank You!VIP MemberGOTM 3RD PLACE! - APRIL 2009Weekly Picture Me This Round 27 Winner!Weekly Picture Me This Round 41 Winner!Weekly Picture Me This Round 45 Winner!
23rd March, 2010 at 16:02:06 -

Hello folks,

I have been reading quite a lot of articles about this subject, but I still have problems. I am sure this is because I suck at coding but I am here to learn.

My main dude has a 360 degree movement, now I want him to be able to shoot (or actually toss hammers). For this I use:

Press fire 2 -> Set posX of "Hammer" to Cos(rotY("player" ))*4
Set posY of "Hammer" to Sin(rotY("player" ))*4


posX and posY are values
rotY is the rotation value of the player

Always -> Set X of "Hammer" to X( "Hammer" )+posX( "Hammer" )
Set Y of "Hammer" to Y( "Hammer" )(posY( "Hammer" )


But this doesn't seem accurate, sometimes it's right, sometimes its a little off, which makes it hard to aim. What am I doing wrong?


 
www.hayovanreek.nl

Solgryn

Solgryn dot org

Registered
  20/12/2008
Points
  12572

GOTW Winner!VIP MemberWii OwnerIt's-a me, Mario!The Cake is a LieGOTM 2ND PLACE! - APRIL 2009GOTM 2ND PLACE - JUNE 2009PS3 OwnerKlikCast #15 Compo Winner!LOL Sign
You've Been Circy'd!GOTM WINNER - JANUARY 2010I am an April FoolGOTW MARCH 2010 WINNER!Santa Hat
23rd March, 2010 at 17:58:52 -

Try multiplying with 4.0 instead of 4 to keep it a floating number

 
www.Solgryn.org

Image

Hayo

Stone Goose

Registered
  15/08/2002
Points
  6946

Game of the Week WinnerHas Donated, Thank You!VIP MemberGOTM 3RD PLACE! - APRIL 2009Weekly Picture Me This Round 27 Winner!Weekly Picture Me This Round 41 Winner!Weekly Picture Me This Round 45 Winner!
23rd March, 2010 at 18:16:49 -

Hmm, tried that but I keep having the same problem. Something else must be rounding it off.

 
www.hayovanreek.nl

Rob Westbrook



Registered
  25/05/2007
Points
  193

360 OwnerVIP Member
23rd March, 2010 at 20:11:44 -

When in doubt I always stick +0.0 at the end of all my expressions. MMF's really picky nature when using floats is really annoying sometimes...

 
There are 10 types of people in the world: Those who understand binary and those who don't.

Solgryn

Solgryn dot org

Registered
  20/12/2008
Points
  12572

GOTW Winner!VIP MemberWii OwnerIt's-a me, Mario!The Cake is a LieGOTM 2ND PLACE! - APRIL 2009GOTM 2ND PLACE - JUNE 2009PS3 OwnerKlikCast #15 Compo Winner!LOL Sign
You've Been Circy'd!GOTM WINNER - JANUARY 2010I am an April FoolGOTW MARCH 2010 WINNER!Santa Hat
23rd March, 2010 at 20:36:21 -

It's not rounding it off it seems... the cos and sin values are precise but MMF doesnt like setting object to 1.5 x position??

 
www.Solgryn.org

Image

Watermelon876



Registered
  16/04/2009
Points
  27

I am an April FoolVIP Member
24th March, 2010 at 02:01:16 -

I am pretty sure your doing it right, but try it without 3D.

 
Awesomeness is Watermelon.
*/l、
゙(゚、 。 7
l、゙ ~ヽ
じしf_, )ノ
This is Koji. Copy and paste Koji to your sig so he can acheive world domination.

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th March, 2010 at 02:23:04 -

"posX" and "posY" are actually "velocities", not "positions".

You need to store the positions in alterable values aswell, otherwise they will get rounded off (screen coordinates are always integers).

+ Press fire 2
-> Set velX of "Hammer" to Cos(rotY("player" ))*4
-> Set velY of "Hammer" to Sin(rotY("player" ))*4

+ Always
-> Set posX of "Hammer" to posX( "Hammer" )+ velX( "Hammer" )
-> Set posY of "Hammer" to posY( "Hammer" )- velY( "Hammer" )
-> Set X position of "Hammer" to posX("Hammer")
-> Set Y position of "Hammer" to posY("Hammer")

Edited by Sketchy

 
n/a

Hayo

Stone Goose

Registered
  15/08/2002
Points
  6946

Game of the Week WinnerHas Donated, Thank You!VIP MemberGOTM 3RD PLACE! - APRIL 2009Weekly Picture Me This Round 27 Winner!Weekly Picture Me This Round 41 Winner!Weekly Picture Me This Round 45 Winner!
24th March, 2010 at 14:50:52 -

Yeah, that does the trick. Thanks man

 
www.hayovanreek.nl

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th March, 2010 at 14:57:03 -

No worries. Thanks for the trophy

 
n/a

Watermelon876



Registered
  16/04/2009
Points
  27

I am an April FoolVIP Member
25th March, 2010 at 01:06:20 -

Oh wait, I misread that! Yeah, that's the same problem that happened to the original survival space.

 
Awesomeness is Watermelon.
*/l、
゙(゚、 。 7
l、゙ ~ヽ
じしf_, )ノ
This is Koji. Copy and paste Koji to your sig so he can acheive world domination.
   

Post Reply



 



Advertisement

Worth A Click