I want to make a physics.queryRegion move relative to an object. Is this possible and if it is how would I do it?
Thank you.
I want to make a physics.queryRegion move relative to an object. Is this possible and if it is how would I do it?
Thank you.
Time to push this post up!
A simple sample project would be great for this, if a physics.queryRegion can be moved. Just in case I am not specific enough, can this be moved with an enterFrame so that is follows an object?
I don’t understand the question. If you need the region being queried to change, change the coordinates of the query.
local player = display.newCircle( 10, 10, 10 ) local function queryRegionAboutObject( obj, width ) local hits = physics.queryRegion( obj.x - width/2, obj.y - width/2, obj.x + width/2, obj.y + width/2 ) return hits end local hits1 = queryRegionAboutObject( player, 100 ) player.x = 200 local hits2 = queryRegionAboutObject( player, 100 )
I don’t mean this. I mean if there is someway to create one physics.queryRegion and have it follow an object. (Move continuously with an object through an enterFrame listener, like the thrusters on the ship you helped me with)
A physics query region is not a ‘thing’. It is a calculation done at the moment you request it.
You need an object with a kinematic body that is a sensor.
Tie a collision listener to it that figures out when it hits something.
Then use an enterFrame listener to have have the object follow your target object.
I don’t know what follow means in this instance, but that is the essence of it.
Time to push this post up!
A simple sample project would be great for this, if a physics.queryRegion can be moved. Just in case I am not specific enough, can this be moved with an enterFrame so that is follows an object?
I don’t understand the question. If you need the region being queried to change, change the coordinates of the query.
local player = display.newCircle( 10, 10, 10 ) local function queryRegionAboutObject( obj, width ) local hits = physics.queryRegion( obj.x - width/2, obj.y - width/2, obj.x + width/2, obj.y + width/2 ) return hits end local hits1 = queryRegionAboutObject( player, 100 ) player.x = 200 local hits2 = queryRegionAboutObject( player, 100 )
I don’t mean this. I mean if there is someway to create one physics.queryRegion and have it follow an object. (Move continuously with an object through an enterFrame listener, like the thrusters on the ship you helped me with)
A physics query region is not a ‘thing’. It is a calculation done at the moment you request it.
You need an object with a kinematic body that is a sensor.
Tie a collision listener to it that figures out when it hits something.
Then use an enterFrame listener to have have the object follow your target object.
I don’t know what follow means in this instance, but that is the essence of it.