unity3d - Unity box to Mouse issue -
i having issue code, i'm trying move 3d box variable of position of mouse, need know how change box's x,y,z mouse position script. im asking really, how change boxes x,y,z variable in script. thanks!
code:
#pragma strict public var distance : float = 4.5; var box = transform; private var firstobject : cube; function start () { } function update () { castraytoworld(); } function castraytoworld() { var ray : ray = camera.main.screenpointtoray(input.mouseposition); var point : vector3 = ray.origin + (ray.direction * distance); debug.log( "world point " + point ); firstobject = gameobject.find("pos").getcomponent("cube").pos = point; firstobject.pos = point; }
make sure other object aware of box gameobject (lets under name 'adjustable'), case of:
adjustable.transform.position = new vector3(x, y, z)
to make sure object aware of boxes gameobject, make adjustable public variable, , manual drag box scene field created in component on object in question.
Comments
Post a Comment