Drag Speed
Hi, Im currently trying to work out an actors speed while its being dragged around, as i need the actors speed when it collides with another actor, so ive started a new project just to test this.
I have 3 actors one to display the current speed in text, the dragger, and the collider.
To drag the dragger, im using [when touch is down constrain attribute self.position.x to game.mouse.position.x] same for Y, the dragger is also set to move to default a position on release at a speed of 500.
i have a real attribute in the game called Speed, which is being displayed by the text actor.
i have set a rule [when touch is down constrain attribute game.speed = self.motion.linear velocity.x] when i drag around the actor nothing happens until i let go and to the text changes to 500
ive tried other suggestion and samples in this forum and i cant get it to work would be grateful of any advice thanks
Comments
if i use magnitude( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ) again it only works on release so im assuming it has something to do with the way the actor is being moved around
The constrain behaviour doesn't use the physics engine, so the actor is not actually moving (according to the physics engine), so it will not have a velocity.
There are ways to achieve what you want, but moving an actor by hand (dragging) will result in the speed display flickering around like crazy (unless you quantized it . . . ?)
Let me try make a demo . . . .
A quick idea of one way you might be able to do it . . . . ? (File attached).
Even with quantizing the X velocity value to 100s it still jumps between values, you'd have to be superhuman to be able to drag an object at a consistent speed.
This version might be a little better, it updates the speed every 0.2 seconds rather than constantly updating . . . (File attached).
Abosultely Brilliant, Thank you
hi, just a quick question how do you have "Current Scene"
You need to unlock an actor while it is in the scene to be able to access scene attributes.