I have a proticulary nasty problem in my cinco de maya project, thought some of you newton fanboys could help out a bit
Basicly, I need a very fast method of pointing a newton object in a specefic direction (I'm planning on having up to 80 enemys on screen at one time
) Currently, I have:
HandleEnemys2:
for i = 0 to TOTALENEMYS
if e(i).active = 1
eb=NDB_Getbody( e(i).obj )
`enemy rotation
ay# = e(i).r
position object d, opx( e(i).obj ), opy( e(i).obj ), opz( e(i).obj )
point object d, opx( p1.obj ), opy( p1.obj ), opz( p1.obj )
`yrotate object d, opy(d)+180
e(i).dest_y = oay(d)
`figure out which way to turn
c# = ay# - e(i).dest_y
if c# < 0 then inc c#,360
if c# > 180
inc e(i).r, turn_force#
endif
if c# < 180
dec e(i).r, turn_force#
endif
if e(i).r > 360 then e(i).r = 0
if e(i).r < 0 then e(i).r = 360
NDB_SetVector 1, 0.0, 5.0, 0.0
NDB_SetVector 2, 0.0, 0.0, 2
NDB_BodyAddForceLocal eb
if e(i).health =< 0 then e(i).active = 0
`debug health info
if object in screen( e(i).obj ) then text object screen x( e(i).obj ), object screen y( e(i).obj )-22, str$( e(i).health )
endif
`we want him pointed at his last destination (even if he is dead and should fall to teh ground)
yrotate object e(i).obj, e(i).r
`make sure his feet don't stick through the floor :P
move object up e(i).obj, 0.4
next i
return
Not very understandable, I know
Mostly because I already have a handful of workaround in there (e(i).r, namely) Problem: I need to be able to manually control the newton collider's y rotation. (The bad guys don't shoot at you isasmuch charge with claws) Second problem: how do I limit the velocity that I apply with the
NDB_BodyAddForceLocal? I don't exactly want them accelerating in an insane fashion... I know how to get the current velocity with
NDB_NewtonBodyGetVelocity but I don't want the velocity on the global scale, just the local scale (because I'm applying a local force)
The alternative to all of this, using global forces instead of local, makes it drop down from 65 fps to a megre 18
(and that's with a megre 18 enemys--remember I want around 60-80)
Any ideas?