BOB_ROX Posted July 7, 2010 Report Share Posted July 7, 2010 Hello, I havent been on here for awhile now. But I got some trouble with my game, Or so far with a game. Im using the genesis engine, And Im having trouble with homing attack and targetting system, Now I had some help with getting the homing and jump dash and all. But when Sonic goes towards the target he keeps going towards the right. Always. I was wondering if I could have some help. Heres the code I got off a friend to help me. //enemy=instance_nearest(x,y,enemy_basic)if ( action == action_normal || action == action_jumping || action = action_spring_jump || ((shield == 3 || shield == 4) && action == action_shield)) //if jumping or homing attack bouncing{if key_action_pressed && delay=0 && distance_to_object(objEnemy)<50 //If you press 'Z' and are close to an enemy{action = action_jumping //change to homing actionsound_play(sndAirAttack) //Play homing sound//Lock on to nearest enemy (Notice I switch from Damizean's hsp,vsp function to speed and direction then back)if instance_number(objEnemy)>0{if lock=1 && distance_to_object(objEnemy)<50 && objEnemy.y>=y //Go towards enemy{direction=point_direction(x,y,objEnemy.x,objEnemy.y) speed=5 hsp=0 vsp=0}elseif lock=1 && speed>0 //Cancel lock (too far away from enemies){lock=0 hsp=hspeed vsp=vspeed speed=0}}elseif lock=1 && speed>0 //Cancel lock (If no enemies are present){lock=0 hsp=hspeed vsp=vspeed speed=0}//If there is a wall between you and an enemy, stop homing attack (also applies to layers)if instance_number(objEnemy)>0{if collision_line(x,y,objEnemy.x,objEnemy.y,objSolid,1,1) && lock=1{vsp=0 hsp+=animation_direction*6 lock=0 speed=0}elseif collision_line(x,y,objEnemy.x,objEnemy.y,objHigh,1,1) && lock=1 && layer=0{vsp=0 hsp+=animation_direction*6 lock=0 speed=0}elseif collision_line(x,y,objEnemy.x,objEnemy.y,objLow,1,1) && lock=1 && layer=1{vsp=0 hsp+=animation_direction*6 lock=0 speed=0}elseif collision_line(x,y,objEnemy.x,objEnemy.y,objBridge,1,1) && lock=1{vsp=0 hsp+=animation_direction*6 lock=0 speed=0}}}}if instance_number(objEnemy)>0 && distance_to_object(objEnemy)<50//Locked on (enemy must be in-line or below Sonic, not above){lock=1}if lock=1 && distance_to_object(objEnemy)<50 && instance_exists(objLock)=0{instance_create(objEnemy.x,objEnemy.y,objLock)}[/CODE]Ive had other people check it out and so far NO ONE can figure it out, I sent it back to the guy who gave it to me but I never heard from him after that. And he even says he doesnt have a clue it was something slap together. So please can anyone help me out?Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts