03-30-2011, 11:25 PM 
		
	
	
		I need to make a script where one box turns and points (rotates so that the top side is facing) at another box. How would I go about doing that? (Paging Jacob_...)
	
	
	
	
	
| The following warnings occurred: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Warning [2] Undefined array key "lockoutexpiry" - Line: 94 - File: global.php PHP 8.4.12 (Linux) 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 
| 
					How do I make one part point towards another?
				 | 
| 
		
		
		03-30-2011, 11:25 PM 
		
	 
		I need to make a script where one box turns and points (rotates so that the top side is facing) at another box. How would I go about doing that? (Paging Jacob_...)
	 
		
		
		03-30-2011, 11:48 PM 
		
	 
		I made a tool to make a part point towards the mouse. Is it close enough to what you need? [lua] part = game.World.MyPart function normalizeVector(vec) local m = math.sqrt(vec.x * vec.x + vec.y * vec.y) return Vec2D(vec.x / m, vec.y / m) end function dragged(b, pos) if b == 1 then local v = normalizeVector(Vec2D(pos.x - part.Position.x, pos.y - part.Position.y)) local a = math.deg(math.atan2(v.y, v.x)) part.Rotation = a end end link(script.Parent.MouseDragged, dragged) [/lua] 
		AWSOME, thanks! Here's my edited code, in case anyone else wants to use it: [lua] part = game.World.Box1 function normalizeVector(vec) local m = math.sqrt(vec.x * vec.x + vec.y * vec.y) return Vec2D(vec.x / m, vec.y / m) end function dragged(b, pos) if b ~= nil then local v = normalizeVector(Vec2D(pos.x - part.Position.x, pos.y - part.Position.y)) local a = math.deg(math.atan2(v.y, v.x)) part.Rotation = a end end link(game.World.Box2.PropertyChanged, function(prop, value) if prop == "Position" then dragged(game.World.Box2, value) end end) [/lua] Box1 is the part that turns, it points at Box2. 
		
		
		04-03-2011, 05:25 AM 
		
	 
		Sweet. We need the MouseDown event to return the angle of where you clicked, though. Make it a lot easier. 
	 
		
		
		04-03-2011, 07:19 PM 
		
	 
		Use the getAngle() function of the tool: http://buildism.net/forum/Thread-2-4-11?...t=getangle
	 
		
		
		04-04-2011, 10:02 AM 
		
	 
		Cool. This will come in handy.
	 | 
| 
					« Next Oldest | Next Newest »
				 |