How do I rotate 3d camera using Touch plugin?

0 favourites
  • 2 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • Its possible?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There are many ways to do that.

    One is to just use the touch location when you tap. Use it with a non scrolling layer. You can subtract the center of the screen to make it so tapping the center of the screen centers the view.

    touch.x-screenwidth/2, touch.y-screenheight/2

    Another is to change the rotation values based on how far you drag.

    Roughly this. You'd want to get touch coordinates from a non 3d layer.

    var rotx=0
    var roty=0
    var oldx=0
    var oldy=0
    
    on touch
    -- set oldx to touch.x
    -- set oldy to touch.y
    
    is touching
    -- add touch.x-oldx to rotx
    -- add touch.y-oldy to roty
    -- set rotation to rotx, roty
    -- set oldx to touch.x
    -- set oldy to touch.y

    At least that's something to try. You may run into gimbal lock or rotation in a non desirable way but it depends on what you're doing.

    Worst case I'd do the rotation math directly with a 3x3 matrix and apply that with the look at action. It would give the most control of how you rotate. Like instead of the arbitrary euler angles like when you set the rotation you can rotate by any axis such as one relative to the screen. But I may be overthinking it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)