Bouncing Item

Blitz3D Forums/Blitz3D Programming/Bouncing Item

Neochrome(Posted 2004) [#1]
there is a forum for this, but its not clear
I want to bounce an object of a world

a pivot, and a spinning star, the star is parented to the pivot which is moving

pointentity pivot, localplayer

then in a game loop

moveentity pivot, 0, 0, 4

if entitycolided(pivot,coll_world)
' i cant remember what to do here, i want the item to bounce
end if


semar(Posted 2004) [#2]
[Very rough method, which is an offence to Newton physic]

You could, for example, when you want your pivot bouncing:
- create a new pivot just behind your main one
- point to it with pointentity
- move your main pivot, which now will move in the opposite direction, thus bouncing
- destroy the just created pivot with FreeEntity

OR (easyer:)
- if collision then
-- TurnEntity 0,90,0
-- MoveEntity...

Bare in mind that if you, in your main loop, point your entity again toward the locaplayer, then your pivot will change again direction, so you have to make the pointentity direction once - before the mainloop, and then change the direction only when it collides.

Hope this helps,
Sergio.


Neochrome(Posted 2004) [#3]
the turn entity 90 wouldn't help, and yeah thats a very big offence to Newton Physics! LOL

i did it onces using CollidedNX and NY and NZ stuff. But cant remember how :(


semar(Posted 2004) [#4]
Oh yes, the TurnEntity 0,90,0 assumes that your object travels on a plane parallel to the xy plane, which I guess is not the case !

Hum... have you tryed the first method ? Of course you have to calculate the place where to put the new pivot, depending on the pitch, roll and yaw of the main pivot..

8)

Sergio.

P.S.
Sorry Newton !


Neochrome(Posted 2004) [#5]
using pivots like that would be fragmenting memory.

hmm, i think translateentity had something to do with it, oh this is going to take a while! :(


Neochrome(Posted 2004) [#6]
not working quite as i hoped, this seems to work, but its not realy very good
nx# = CollisionNX#(loopStar\pivot%,cloop)
ny# = CollisionNY#(loopStar\pivot%,cloop)
nz# = CollisionNZ#(loopStar\pivot%,cloop)
AlignToVector loopStar\pivot%, nx#, ny#, nz#, 3,1



Neochrome(Posted 2004) [#7]
i got it!

; Launch the item

	PointEntity newStar\pivot%, Target
	
	TFormNormal 0, 0 , 1, newStar\pivot%,0
	
	newStar\vx# = TFormedX#()
	newStar\vy# = TFormedY#()
	newStar\vz# = TFormedZ#()


;Moving the item, Make sure that the translate AFTER the vDot# calculations!

	If EntityCollided(loopStar\pivot%, coll_world)
		ecoll = CountCollisions(loopStar\pivot%)
		For i=1 To ecoll
			nx# = CollisionNX#(loopStar\pivot%,i)
			ny# = CollisionNY#(loopStar\pivot%,i)
			nz# = CollisionNZ#(loopStar\pivot%,i)
			

		Next
	End If

	Translateentity loopStar\pivot%, loopStar\vx#, loopStar\vy#, loopStar\vz#



msg to neomancer : target practice / bouncing / bounce / collision