Push object away from explosion center with tForm

Blitz3D Forums/Blitz3D Programming/Push object away from explosion center with tForm

Neochrome(Posted 2007) [#1]
im struggling with tFormVector and tFormPoint

TFormPoint  EntityX(lpTank\lpModel),EntityY(lpTank\lpModel),EntityZ(lpTank\lpModel),  lpTank\lpModel, lpExploded\lpModel
						
tfx# = TFormedX()*speed#
tfy# = TFormedX()*speed#
tfz# = TFormedZ()*speed#
						
						
MoveEntity lpTank\lpModel,tfx,0,tfz


what i want is the object to move away from the explosion!

i cant seem to get this right, i've tried TranslateEntity, and moveEntity, tForm and otehr algorythms, trouble is, i've done this before but i cant for the life of me remember HOW i did it! (lost my code due crashed HD)


Dreamora(Posted 2007) [#2]
what is speed? just to make sure its not 0 :-)


Neochrome(Posted 2007) [#3]
speed is the distance, i want the impact of this explosion to be lesser the further away it is


big10p(Posted 2007) [#4]
You don't need TForm to find the vector from the explosion to the tank:
vx# = EntityX(tank,1) - EntityX(explosion,1)
vz# = EntityZ(tank,1) - EntityZ(explosion,1)

This is just the 2D XZ vector as it seems from your code that you're not interested in the Y component.


Neochrome(Posted 2007) [#5]
what about the impacted speed?
the further away from the explosion the effect of the blast shouldn't be so great?


big10p(Posted 2007) [#6]
Off the top of my head and not tested, something like this?
ent_dist# = Abs(EntityDistance(tank,explosion))
If ent_dist# <= BLAST_RADIUS
	vx# = EntityX(tank,1) - EntityX(explosion,1)
	vz# = EntityZ(tank,1) - EntityZ(explosion,1)
	dist# = Sqr(vx * vx + vz * vz)
	nx# = vx# / dist#
	nz# = vz# / dist#
	
	bs# = BLAST_SPEED - (BLAST_SPEED * (ent_dist# / BLAST_RADIUS))
	blast_x# = nx# * bs#
	blast_z# = nz# * bs#
	
	TranslateEntity tank,blast_x#,0,blast_z#
EndIf



Neochrome(Posted 2007) [#7]
thanks loads big10p :)

i've sorta used something like this

tfx# = EntityX(lpTank\lpModel) - EntityX(lpProxy\lpModel)
						tfz# = EntityZ(lpTank\lpModel) - EntityZ(lpProxy\lpModel)
			
						dist# = (EntityDistance(lpProxy\lpModel, lpTank\lpModel))
			
						tfx=(tfx/(dist*dist)* 1000)
						tfz=(tfz/(dist*dist)* 1000)
						
						;MoveEntity lpTank\lpModel,tfx,0,tfz
						lpTank\lDisplaceX# = tfx
						lpTank\lDisplaceZ# = tfz


works for what i need :)

thanks again tho guys :)