Attaching A Camera To An Object


i'm putting demonstration of user-controlled ball rolling around on piece of land , i'd camera follow ball distance (i.e. have camera move along same axis ball it's position in sky) having trouble doing this. terminology or syntax should use this, , whereabouts in code should fit?

my code follows:


quote:

global w, hk, rb, vplaneh, rb2


on beginsprite me

createphysicalobjects()

end


on createphysicalobjects me


-- ball
m = w.model("marble")
m.addmodifier(#meshdeform)
rb = hk.makemovablerigidbody(m.name, 100)
rb.restitution = 2
rb.friction = 500

-- ground
m = w.model("landscape")
m.addmodifier(#meshdeform)
rb2 = hk.makefixedrigidbody(m.name, false)

-- invisible bottom
vplanemr = w.newmodelresource("ground", #box)
vplanemr.height = 10
vplanemr.width = 225
vplanemr.length = 225

vpfixed = w.newmodel("bottom", vplanemr)
vpfixed.transform.position = vector (0, 0, -20)
vpfixed.transform.rotation = vector (90, 0, 0)
--vpfixed.visibility = #none
vpfixed.addmodifier (#meshdeform)
--vpfixed.visibility = #none

vpfixedh = hk.makefixedrigidbody ("bottom", true, #box)

hk.gravity = vector (0, 0, -100)

end


on exitframe me

-- x axis (red) point left, y axis (green) points towards camera , z axis (blue) points

-- marble movement
if keypressed (126) rb.applyimpulse (vector (-300, 0, 0 ))
else if keypressed (125) rb.applyimpulse (vector (300, 0, 0))
else if keypressed (123) rb.applyimpulse (vector (0, 300, 0))
else if keypressed (124) rb.applyimpulse (vector (0, -300, 0))

end if


i've managed transform camera suitable position marble.

quote:

w.camera[1].transform.position = vector (-350, -350, 250)


this perfect starting viewpoint, though still cannot find right code attaching it.

can't me this, please?

i tearing hair out here.


More discussions in Director Lingo


adobe

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial