for those that have played around with cRobots or even better the one im trying
to reproduce based on Atari version where you soldered up a circuit and tested
your robot against others in a battle
here is the
prototype
here is the
3D version models courtesy of blink
Edited video removed for space
the robots has some lovely animations which im still yet to implement properly
but atm I have the robots moving around shooting if there is something in radar
and slashing if its close
lots to do yet
what I cant seem to get right atm is the shoot routine. which basically works as there
is an object attached to the arm that moves a sort of invisible gun
heres the code I use
function robotShoot(robotObj as integer, initialSpeed as float, mass as float)
//To move dynamic physics bodies we need to apply velocity to the physics body.
gunPositionVec= CreateVector3(GetObjectWorldX(robotObj),GetObjectWorldY(robotObj),GetObjectWorldZ(robotObj))
//Create a tempory projectile block to calculate movement vectors of bullets
projectileDirBox as integer
projectileDirBox = CreateObjectBox( 1.0, 1.0, 1.0 )
SetObjectPosition( projectileDirBox, GetVector3X( gunPositionVec ), GetVector3Y( gunPositionVec ), GetVector3Z( gunPositionVec ))
setobjectrotation(projectiledirbox,GetObjectWorldAngleX(robotObj),GetObjectWorldAngleY(robotObj),GetObjectWorldAngleZ(robotObj))
MoveObjectLocalZ( projectileDirBox, -1 )
projectileDirVec = CreateVector3( GetobjectWorldX( projectileDirBox )-GetVector3X( gunPositionVec ), GetobjectWorldY( projectileDirBox )-GetVector3Y( gunPositionVec ), GetobjectWorldZ( projectileDirBox )-GetVector3Z( gunPositionVec ) )
DeleteObject( projectileDirBox )
bullet as integer
bullet = CreateObjectSphere( .5,.5, 16 )
SetObjectColor( bullet, 255, 0,0,255 )
SetObjectPosition( bullet, GetVector3X( gunPositionVec ), GetVector3Y( gunPositionVec ), GetVector3Z( gunPositionVec ))
//3D Physics code
Create3DPhysicsDynamicBody( bullet )
SetObjectShapeSphere( bullet )
SetObject3DPhysicsMass( bullet, mass )
SetObject3DPhysicsLinearVelocity( bullet, projectileDirVec, initialSpeed )
myItem as bullet
myItem.ID = bullet //the object id of the bullet
myItem.time = timer() //timer is used to set there life time as bullets will die off after so long
myBullet.insert(myItem) //update bullet arrow as there is unlimeted bullets
inc bulletCount //used for a bullet counter to check if theyve timed out or not
deletevector3(projectileDirVec)
deletevector3(gunPositionVec)
endfunction
the movements for the robots i havent used the move commands instead i opted to calculate the
forwardmovementvector and using that to set the objects position. I may change this yet not sure
function getMovementVector(robotObj,ammount as float)
positionVec= CreateVector3(GetObjectWorldX(robotObj),GetObjectWorldY(robotObj),GetObjectWorldZ(robotObj))
//Create a tempory projectile block to calculate movement vectors of bullets
projectileDirBox as integer
projectileDirBox = CreateObjectBox( 1.0, 1.0, 1.0 )
SetObjectPosition( projectileDirBox, GetVector3X( positionVec ), GetVector3Y( positionVec ), GetVector3Z( positionVec ) )
setobjectrotation(projectiledirbox,GetObjectWorldAngleX(robotObj),GetObjectWorldAngleY(robotObj),GetObjectWorldAngleZ(robotObj))
MoveObjectLocalZ( projectileDirBox,ammount )
//forwardVec = CreateVector3( GetobjectWorldX( projectileDirBox )-GetVector3X( positionVec ), GetobjectWorldY( projectileDirBox )-GetVector3Y( positionVec ), GetobjectWorldZ( projectileDirBox )-GetVector3Z( positionVec ) )
Update3D(0)
forwardVec= CreateVector3( GetobjectWorldX( projectileDirBox ), GetobjectWorldY( projectileDirBox ), GetobjectWorldZ( projectileDirBox ))
DeleteObject(projectileDirBox)
DeleteVector3(positionVec)
endfunction forwardVec
But my question is does anyone see an issue with the robotshoot function as I cant ?