Changine missle direction angle?

Non-platform specific questions.

Changine missle direction angle?

Postby Hblade » Wed Aug 04, 2010 7:55 pm

Okay, I have a missile and it fails to change its animpos :( Its a homing missile, I have the homing part down pact but its the changing the animation is the problem >.>

How would I have it change? Its an 8 frame missile, here:
missle.gif
missle.gif (1 KiB) Viewed 812 times


I need it to change as if it's really homing in on the player :o
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Changine missle direction angle?

Postby savvy » Wed Aug 04, 2010 8:18 pm

use this:
Code: Select all
angle=direction(x,y,-target-.x,-target-.y);animpos=(angle/360)*-amount of frames(8)-;
change the amount of frames to 8 in your case, and the target to what its homing in on.
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: Changine missle direction angle?

Postby Hblade » Wed Aug 04, 2010 8:35 pm

Thanks savvy :D!
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Changine missle direction angle?

Postby savvy » Wed Aug 04, 2010 9:27 pm

np
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: Changine missle direction angle?

Postby Hblade » Thu Aug 05, 2010 2:00 pm

The variable called "nframes" will tell you how much frames is in 1 animation :D so use -nframes instead of 8 :3
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Changine missle direction angle?

Postby DilloDude » Thu Aug 05, 2010 2:06 pm

If you already know the number of frames (which you should, considering you made the animation) you can just use the number of degrees.
Code: Select all
animpos = angle / 45;

This only uses one division, so is more efficient.
Even better, you can do a multiplacation - take the angle - in this case 45 - and divide 1 by it. 1 / 45 = 0.022222222222222222222222222222222
That would be
Code: Select all
animpos = angle * 0.022222222222222222222222222222222;

This is not quite such a nice number for it, so you may want to divide anyway. But when it becomes a nice compact number, such as .1 or .025 or whatever, you can multiply.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest