Hi there
Recently, I’ve been working on a turret that is controlled by the computer. It turns to the player and fires at the player. But in the first place, I couldn’t make it move…
I’ve figured out the following codes:
onClipEvent (load) {
var turning = 2
var dx:Number
var dy:Number
var angle:Number
}
onClipEvent (enterFrame) {
dx = this._x - _root.player._x
dy = this._y - _root.player._y
angle = Math.atan(dx/dy)
if (this._rotation < angle) {
this._rotation += turning
}
if (this._rotation > angle) {
this._rotation -= angle
}
}
I’m sure that it’s full of bugs. Please tell me where.
Got something to do with radians?