How to move object to event position?

I’m coming back to Corona after a several month hiatus and am trying to get back into the swing of things. I know I did a tutorial regarding the same exact problem I’m having, but I can’t seem to find it. I have been trying for 20 minutes to get a function which moves an object to the event position to work, but I’m not having any luck. In other words, wherever you touch, the object will follow right below your finger, where the touch event is.

  
\_W = display.contentWidth;  
\_H = display.contentHeight;  
mRand = math.random  
  
rampWidth = \_W/3;  
rampHeight = \_H/20;  
rampBounce = 0.5;  
rampFriction = 1.0;  
-- Create first ramp (TEST) --  
  
ramp1 = display.newRect( 0, 0, rampWidth, rampHeight );  
ramp1:setReferencePoint(display.CenterReferencePoint);  
ramp1.x = \_W/3; ramp1.y = \_H/2;  
ramp1.rotation = 30;  
physics.addBody( ramp1, "static", {friction = rampFriction, bounce = rampBounce} );  
  
----- FUNCTIONALITY OR LACK THEREOF ------  
  
-- Move ramp --  
  
function moveRamp(event)  
 ramp1 = event.target  
 event.x = ramp1.y  
 event.y = ramp1.y  
end  
  
ramp1:addEventListener( "touch", moveRamp )  
  

Much thanks to anyone who can help out! [import]uid: 66386 topic_id: 22198 reply_id: 322198[/import]

You’re saying event.x = ramp.x - try ramp.x = event.x :wink: [import]uid: 52491 topic_id: 22198 reply_id: 88296[/import]

Peaches to the rescue again! I don’t know how that slipped by me- thanks a lot! [import]uid: 66386 topic_id: 22198 reply_id: 88298[/import]

Haha, no worries. (Easy to make little mistakes like this when you’re rusty.) :slight_smile: [import]uid: 52491 topic_id: 22198 reply_id: 88319[/import]