Notifications
Clear all

[Closed] How to constraint an object to a normalized vector

Hey, I’m trying to constraint an oject to a normalized vector or a radius.
Thing is I want to use only 1 node so I need to put the constraint while keeping the posXYZ on the same object.

I still want to be able to move this object freely so I still need the pos XYZ.

Kinda like an attachment constraint on a sphere when the set position is on.

So far ive been able to constraint my object to a normalize vector using a simple position script but then I loose the ability to move it and have to move it using another controller.

is this possible? if yes How?

7 Replies
1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

Are you try to use “Position List” controller? That way works “Freeze Transform” from quad menu.

Thanks, but that’s not what I want to achieve. I dont want the tracks the be frozen and store a 0 position/rotation. I want to snap an object on an invisible sphere and be able to move it while being attached to this invisible sphere so AT ALL TIME his distance from the origin of the invisible sphere is the lenght of the sphere radius or the normalized vector


 with redraw off, undo off
 (
 	delete objects
 	
 	b = box name:"sticky" width:10 length:10 height:10 pos:[0,0,1] wirecolor:orange isselected:on
 	s = sphere name:"imaginary" radius:50 segments:32 wirecolor:gray
 
 	c = b.position.controller = Position_List()
 	c.setname c.count "Free Position" 
 	s = c.available.controller = Position_Script()
 	c.setname c.count "Sticky Script"
 
 	s.addconstant "radius" 50
 	s.addobject "free" b.position.controller[1].controller
 	s.setexpression "(normalize free.value)*radius - free.value"
 
 	s = b.rotation.controller = Rotation_Script()
 	s.addobject "pos" b.position.controller
 	s.setexpression "(arbAxis (normalize pos.value)).rotation"
 )
 

as usually after i show a solution many say: “Of course. It’s so simple…”

Cool, didnt really need the ball tho but getting rid of it was quick easy anyway. Thanks for the tip.

The box is pretty sensible tho, i’ll try to slow it down

check how i call the ball in my sample…

no worries that was already fixed when I posted as i sad this was an easy fix

 em3

Thank you, Denis!