r543
Relic Team
Posts: 408
|
Post by r543 on Apr 21, 2012 10:44:59 GMT -5
that's the code that i use on objects If EntityDistance(o\Entity,p\Objects\Entity)<=20 And (p\Action = ACTION_Lightdash) Then PointEntity p\Objects\Entity,o\Entity MoveEntity p\Objects\Entity,1,1,1 EndIf
|
|
Jloy2
Full Member
Moving at a somewhat fast pace!
Posts: 191
|
Post by Jloy2 on Apr 21, 2012 20:38:59 GMT -5
There is one major bug with this. It targets ALL entities that are 20 or less units close with this code applied on it.
|
|
r543
Relic Team
Posts: 408
|
Post by r543 on Apr 22, 2012 6:26:59 GMT -5
There is one major bug with this. It targets ALL entities that are 20 or less units close with this code applied on it. yes , do you know what i should add that it only moves to the nearest ?
|
|
|
Post by Marble (LS5) on Apr 22, 2012 13:36:02 GMT -5
This here is my version.
Put this part in Stage_Step and add whatever fields need to be added. The reason it is in Stage_Step is because it would be unwise to put this portion in the object update code. It will cause the player's homing speed to be multiplied by the objects around him. Better put this in Stage_Step.
For p.tPlayer = Each tPlayer If (p\Homing = 1) Then MoveEntity(p\Objects\Entity,0,3.5*Game\DeltaTime\Delta#,0) EndIf Next
This part would go where you want Sonic to home onto an enemy. It also includes a timer, this helps a lot.
If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 50) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 50) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 50 And p\Action = ACTION_JUMPDASH) Then ;PositionEntity(p\Objects\Entity,o\Position\x#,o\Position\y#,o\Position\z#) ; p\EnemyX# = o\Position\x# ; p\EnemyY# = o\Position\y# ; p\EnemyZ# = o\Position\z# p\Action = ACTION_HOMING : p\HomingTimer = MilliSecs() + 2000 : p\Motion\Speed\y# = 0 : p\EnemyZ# = o\Position\z# : p\EnemyY# = o\Position\y# : p\EnemyX# = o\Position\x# ;p\Motion\Speed\x# = 0 ;p\Motion\Speed\z# = 0 EndIf If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 55) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 55) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 55 And p\Action = ACTION_HOMING) Then ;PositionEntity(p\Objects\Entity,o\Position\x#,o\Position\y#,o\Position\z#) If (p\HomingTimer < MilliSecs()) Then p\Action = ACTION_FALL EndIf AlignToVector(p\Objects\Entity, ex#, ey#, ez#, 2, .80) AlignToVector(p\Objects\Mesh, ex#, ey#, ez#, 2, .80) p\Homing = 1 p\Motion\Speed\x# = 0 p\Motion\Speed\z# = 0
; Destroy Enemy Goes Here, as well as "p\Homing = 0"
EndIf
Homing function is just an empty player function with the exception of "If Ground True Then Land" command if you wish to put it there. JumpDash will lead into Homing if the player is close enough.
|
|
|
Post by sonicman19984eva on Apr 22, 2012 15:20:03 GMT -5
would of thought u LS5 would be a resource guy cause u sure are
|
|
r543
Relic Team
Posts: 408
|
Post by r543 on Apr 23, 2012 3:48:39 GMT -5
This here is my version. Put this part in Stage_Step and add whatever fields need to be added. The reason it is in Stage_Step is because it would be unwise to put this portion in the object update code. It will cause the player's homing speed to be multiplied by the objects around him. Better put this in Stage_Step. For p.tPlayer = Each tPlayer If (p\Homing = 1) Then MoveEntity(p\Objects\Entity,0,3.5*Game\DeltaTime\Delta#,0) EndIf Next This part would go where you want Sonic to home onto an enemy. It also includes a timer, this helps a lot. If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 50) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 50) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 50 And p\Action = ACTION_JUMPDASH) Then ;PositionEntity(p\Objects\Entity,o\Position\x#,o\Position\y#,o\Position\z#) ; p\EnemyX# = o\Position\x# ; p\EnemyY# = o\Position\y# ; p\EnemyZ# = o\Position\z# p\Action = ACTION_HOMING : p\HomingTimer = MilliSecs() + 2000 : p\Motion\Speed\y# = 0 : p\EnemyZ# = o\Position\z# : p\EnemyY# = o\Position\y# : p\EnemyX# = o\Position\x# ;p\Motion\Speed\x# = 0 ;p\Motion\Speed\z# = 0 EndIf If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 55) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 55) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 55 And p\Action = ACTION_HOMING) Then ;PositionEntity(p\Objects\Entity,o\Position\x#,o\Position\y#,o\Position\z#) If (p\HomingTimer < MilliSecs()) Then p\Action = ACTION_FALL EndIf AlignToVector(p\Objects\Entity, ex#, ey#, ez#, 2, .80) AlignToVector(p\Objects\Mesh, ex#, ey#, ez#, 2, .80) p\Homing = 1 p\Motion\Speed\x# = 0 p\Motion\Speed\z# = 0
; Destroy Enemy Goes Here, as well as "p\Homing = 0"
EndIf Homing function is just an empty player function with the exception of "If Ground True Then Land" command if you wish to put it there. JumpDash will lead into Homing if the player is close enough. blitz 34d can't find the typefield p\Homing = 1
|
|
Jloy2
Full Member
Moving at a somewhat fast pace!
Posts: 191
|
Post by Jloy2 on Apr 23, 2012 6:04:26 GMT -5
This is how my Homing system works.
Each object has the variable "o\CanObjectHoming". I use an updating function to detect when the player is around an object that has this variable set to true. When there is at least one, it triggers the update (Player_Homing_Update) and creates a "list" of all the objects around the player. It then checks through each entry in this list and finds which is the smallest one. It then sets it to the variable "p\Homing\ClosestObject". After this, it sets a vector position to the "Closest Object's" position. The moment the player is in the Homing action, it triggers another variable, "p\Homing\HomingLocked = true" which makes the list stop updating the closest target. Coincidentally, LS5's code is very similar to what I used for the movement and it homes the player to those coords. (There is also an invisible cube to make it work properly, it updates to the vector's coords and the player actually homes on that.)
If people would like to see how I made the lists and I can trust you with it, I'll gladly share it with you. Just drop a message in. ;D
|
|
r543
Relic Team
Posts: 408
|
Post by r543 on Apr 27, 2012 1:07:01 GMT -5
This here is my version. Put this part in Stage_Step and add whatever fields need to be added. The reason it is in Stage_Step is because it would be unwise to put this portion in the object update code. It will cause the player's homing speed to be multiplied by the objects around him. Better put this in Stage_Step. For p.tPlayer = Each tPlayer If (p\Homing = 1) Then MoveEntity(p\Objects\Entity,0,3.5*Game\DeltaTime\Delta#,0) EndIf Next This part would go where you want Sonic to home onto an enemy. It also includes a timer, this helps a lot. If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 50) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 50) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 50 And p\Action = ACTION_JUMPDASH) Then ;PositionEntity(p\Objects\Entity,o\Position\x#,o\Position\y#,o\Position\z#) ; p\EnemyX# = o\Position\x# ; p\EnemyY# = o\Position\y# ; p\EnemyZ# = o\Position\z# p\Action = ACTION_HOMING : p\HomingTimer = MilliSecs() + 2000 : p\Motion\Speed\y# = 0 : p\EnemyZ# = o\Position\z# : p\EnemyY# = o\Position\y# : p\EnemyX# = o\Position\x# ;p\Motion\Speed\x# = 0 ;p\Motion\Speed\z# = 0 EndIf If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 55) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 55) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 55 And p\Action = ACTION_HOMING) Then ;PositionEntity(p\Objects\Entity,o\Position\x#,o\Position\y#,o\Position\z#) If (p\HomingTimer < MilliSecs()) Then p\Action = ACTION_FALL EndIf AlignToVector(p\Objects\Entity, ex#, ey#, ez#, 2, .80) AlignToVector(p\Objects\Mesh, ex#, ey#, ez#, 2, .80) p\Homing = 1 p\Motion\Speed\x# = 0 p\Motion\Speed\z# = 0
; Destroy Enemy Goes Here, as well as "p\Homing = 0"
EndIf Homing function is just an empty player function with the exception of "If Ground True Then Land" command if you wish to put it there. JumpDash will lead into Homing if the player is close enough. ok i now addded homing in player.bb but when i start it i get the error variable must be a type at the line If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 50) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 50) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 50 And p\Action = ACTION_JUMPDASH) Then
|
|
3DSawnikku
Relic Team
Pro Coder,Rigger,Animator,GIMP-er,Etc
Posts: 647
|
Post by 3DSawnikku on May 6, 2012 14:14:32 GMT -5
Change ACTION_JUMPDASH to ACTION_HOMING.
|
|
|
Post by Marble (LS5) on May 6, 2012 14:27:56 GMT -5
Do not change anything in that code, it all works as intended.
|
|
3DSawnikku
Relic Team
Pro Coder,Rigger,Animator,GIMP-er,Etc
Posts: 647
|
Post by 3DSawnikku on May 6, 2012 17:24:25 GMT -5
Ok sorry.
|
|
r543
Relic Team
Posts: 408
|
Post by r543 on May 7, 2012 5:17:54 GMT -5
edit: got it now working, you will need to put it in the object code. could you give me the Field enemyz Field enemyy Field enemyx from player.bb without them sonic stops if he is around the enemy radius.
|
|
|
Post by chaosshadic456 on May 12, 2012 17:14:38 GMT -5
This here is my version. Put this part in Stage_Step and add whatever fields need to be added. The reason it is in Stage_Step is because it would be unwise to put this portion in the object update code. It will cause the player's homing speed to be multiplied by the objects around him. Better put this in Stage_Step. For p.tPlayer = Each tPlayer If (p\Homing = 1) Then MoveEntity(p\Objects\Entity,0,3.5*Game\DeltaTime\Delta#,0) EndIf Next This part would go where you want Sonic to home onto an enemy. It also includes a timer, this helps a lot. If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 50) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 50) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 50 And p\Action = ACTION_JUMPDASH) Then ;PositionEntity(p\Objects\Entity,o\Position\x#,o\Position\y#,o\Position\z#) ; p\EnemyX# = o\Position\x# ; p\EnemyY# = o\Position\y# ; p\EnemyZ# = o\Position\z# p\Action = ACTION_HOMING : p\HomingTimer = MilliSecs() + 2000 : p\Motion\Speed\y# = 0 : p\EnemyZ# = o\Position\z# : p\EnemyY# = o\Position\y# : p\EnemyX# = o\Position\x# ;p\Motion\Speed\x# = 0 ;p\Motion\Speed\z# = 0 EndIf If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 55) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 55) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 55 And p\Action = ACTION_HOMING) Then ;PositionEntity(p\Objects\Entity,o\Position\x#,o\Position\y#,o\Position\z#) If (p\HomingTimer < MilliSecs()) Then p\Action = ACTION_FALL EndIf AlignToVector(p\Objects\Entity, ex#, ey#, ez#, 2, .80) AlignToVector(p\Objects\Mesh, ex#, ey#, ez#, 2, .80) p\Homing = 1 p\Motion\Speed\x# = 0 p\Motion\Speed\z# = 0
; Destroy Enemy Goes Here, as well as "p\Homing = 0"
EndIf Homing function is just an empty player function with the exception of "If Ground True Then Land" command if you wish to put it there. JumpDash will lead into Homing if the player is close enough. hey ls5, "homingtimer" is a global?
|
|
3DSawnikku
Relic Team
Pro Coder,Rigger,Animator,GIMP-er,Etc
Posts: 647
|
Post by 3DSawnikku on May 12, 2012 17:31:52 GMT -5
Hey guys how do you make sonic not home attack an object so fast? i want it like bsu or SADX.
|
|
|
Post by EightBitDragon on May 13, 2012 20:40:23 GMT -5
Looks like everyone's homing attack code is the same. The one I slapped together works just like the spring, by aligning the player to the vector given by a pivot that points to the nearest object.
The next step would be either make your homing attack a burst of speed (homing jump-dash) or a real following homing attack. The 'follow' attack would need an additional timer to turn it off after a period of time so that you don't just keep moving toward the object forever, just in case there is something in the way or the object moves.
To make the follow homing attack, you need to stop the other physics like gravity while in the attack, and disable the player's controls so that he or she cannot miss the object by pressing keys. The 'aiming pivot' would follow Sonic and set the vector continuously. From there, its just a matter of setting the initial speed. Sonic will continue along the vector until he hits the object. In theory anyway.
|
|