A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Need Help with Rotation (mouse aiming)

  1. #1
    Senior Member
    Join Date
    Jun 2005
    Posts
    203

    Need Help with Rotation (mouse aiming)

    I know how to get stuff to face the mouse, but the problem comes when my character starts to walk, the further you go to the right, the more the aiming starts to mess up. Anyone know any way of fixing this? Adding the _x value of the character to the _xmouse didnt help....so any ideas? Any way to aim at the mouse without using _xmouse?
    Tsehehehehehe

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Your question is little unclear. _xmouse works very well for mouse aiming and the position of your char should not mess it up.

    Maybe if you could post some code you have so far then someone can fix it.

  3. #3
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    always use _root._xmouse (or a co-ordinate space that is the same as the one your character is in). so if your character is in say a world movie clip then you should use world._xmouse
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  4. #4
    Senior Member
    Join Date
    Jun 2005
    Posts
    203
    here is the code
    Code:
    //rotates the arm
    onClipEvent (enterFrame) {
    	//sets points
    	var oPoints:Object = {x:-20, y:-300};
    	//converts the points to what they would be on the stage
    	_parent.localToGlobal(oPoints);
    	//sets rotation crud
    	myRadians = Math.atan2(_root._ymouse-oPoints.y, _root.mainguy._x+_root._xmouse-oPoints.x);
    	myDegrees = (myRadians*180/Math.PI);
    	//if facing right, rotate so much, otherwise, rotate so much
    	if (_parent.facing == "right") {
    		_rotation = myDegrees;
    	} else {
    		_rotation = myDegrees*-1+180;
    	}
    }
    It works fine when the character is in the stage. But I'm using one of those dynamic cameras that update whats on the stage based on the cameras position, this makes is so that my character can keep walking right, it increases the _xmouse value too much which causes it to mess up. Right now the code has "_root.mainguy._x+_root._xmouse-oPoints.x" and its not differernt than just having "_root._xmouse-oPoints.x", which is stupid because "_root.mainguy._x+_root._xmouse-oPoints.x" should make the _xmouse value stay around the same no matter how far to the right you go.
    Tsehehehehehe

  5. #5
    Senior Member
    Join Date
    Jun 2005
    Posts
    203
    never mind, I figured it out
    Tsehehehehehe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center