parent objects to rolling ball?

Blitz3D Forums/Blitz3D Programming/parent objects to rolling ball?

daaan(Posted 2004) [#1]
hey, another ball rolling question. i want whatever the ball rolls over to stick to it and rotate with it. im using the entityparent command to parent the entity to the rolling ball but each obj that sticks to it just sits there. any ideas?
thanks,


RiK(Posted 2004) [#2]
Katamari damacy anyone?


WolRon(Posted 2004) [#3]
Make sure that you are performing it correctly, I guess. Check that you are referring to the correct local or global coordinates and parenting to the correct entity.


big10p(Posted 2004) [#4]
You're not using RotateMesh to roll the ball are you?


AntonyWells(Posted 2004) [#5]
What's up with all the empty replies?

Anyway, to achieve this, you'll have to parent it yourself.

Just knocked this up, don't blame me if it sets fire to your dog.

type link
    field rX#,ry#,rz#
    field ent1,ent2
end type

function entityParentPosition(entity,parent)
       o.link=new link
       o\rx=entityX(entity)-entityX(parent)
       o\ry=entityY(entity)-entityY(parent)
       o\rz=entityZ(entity)-entityZ(parent)
       o\ent1=entity
       o\ent2=parent
end function

function updateLinks()
    for l.link =each link
        positionEntity l\ent1,entityX(l\ent2)+l\rx,entityY(l\ent2)+l\ry,entityZ(l\ent2)+l\rz
    next
end function


With that you can manually create position only parent/child relationships for one entity at a time.

entityParentPosition(Ball,Camera)

then call updateLinks once per frame.


AntonyWells(Posted 2004) [#6]
What's up with all the dead replies? the one before was by me, some code to help the guy, lost forever..so it's a issue with the site/server it's self?

Making space for bmax!? :)


big10p(Posted 2004) [#7]
???

SpacedMan, put down the suspiciously large cigarette and step away from the computer. :)


AntonyWells(Posted 2004) [#8]
lol, no seriously, the reply before mine, look clearly, there's a border between the two that shouldn't be there. That's all that showed up of my reply. Check off-topic, gfx's post to robbrown(?) empty...noel's two replies..empty.

Don't play with my sanity..you see it too right!? :)


daaan(Posted 2004) [#9]
spacedman, i tried your code and it is not working for me. i am using rotatemesh for the ball. should i be doing other wise?

thanks,


big10p(Posted 2004) [#10]
tank: Use TurnEntity or RotateEntity instead. Look up all the commands in the docs and you should realize why it doesn't work with RotateMesh. ;)

Spaced: Mine's the post before yours and I dont see anything you mention. However, in offtopic GFK's post has you as the last poster even though you haven't posted!?!?!? :O What skin you using?


AntonyWells(Posted 2004) [#11]
Yeah, 'cos I can't even see gfk's post. So I replied 'WTF' Methinks that's the work of the mods though, if they can see gfk's reply, it would have appeared to be a troll..

Skins, just changed from skn3(See off-topic)..and i can see my reply here now..but still not gfk's posts. I'm confused. Very very confused. ;p


daaan(Posted 2004) [#12]
hi, i can't seem to get simple ball rolling to work with using turnentity or rotateentity. any help?

thanks for all the help. these forums are great.


martonic(Posted 2004) [#13]
Make sure the origin of the ball is at its center.


daaan(Posted 2004) [#14]
if i roll my ball in a strait line its fine. but once i say aim it left backwards the actuall rolling looks all jacked up.


Jeremy Alessi(Posted 2004) [#15]
With RotateEntity() you must rotate it an absolute amount ... it doesn't keep track of how much it's been rotated. TurnEntity() will turn the entity by a certain amount from it's current pitch, yaw, and roll.

RotateEntity(Ball, 90, 0, 0) ... will rotate the ball to the same angle every time.

TurnEntity(Ball, 90, 0, 0) will turn the entity 90 degrees from it's current pitch every time you call it.

I suggest using RotateEntity() and keep track of the current pitch, yaw, and roll yourself (can't use Blitz's EntityPitch() EntityYaw() and EntityRoll() because they'll always return a value between -180 and 180.

So ...
If KeyDown(200)
     ballPitch# = ballPitch# + .1
EndIf
If KeyDown(208)
     ballPitch# = ballPitch# - .1
EndIf
RotateEntity(ball, ballPitch#, 0, 0)