ShiVa Developer Forum • View topic - OnTouch move camera up & down on Y to look up & down on page
 

OnTouch move camera up & down on Y to look up & down on page

All about the StoneScript

OnTouch move camera up & down on Y to look up & down on page

Postby zerovector » 2018-07-25 02:41

Hi there,

I have a 3d mesh which is a page and the camera is facing the page from above, so looking down on the page. I want to be able to touch the screen on a mobile device and move the camera only on the y axis and lock x and z. So to allow the user to read up and down the page because you will only be able to view part of the page due to being zoomed in full screen..

Can anyone help me with this, I have tried with onMouseMove which does the touch and mouse click which does it on the page mesh.. But I just want to move the camera up and down the page as you slide your finger up and down.

In other words PAN the screen along x and y with my finger on the mobile screen or a hold down click and move the mouse..

Thanks, maybe useful for others... :)
zerovector
Fresh Boarder
Fresh Boarder
 
Posts: 2
Joined: 2018-07-25 02:19

Re: OnTouch move camera up & down on Y to look up & down on

Postby zerovector » 2018-07-26 05:08

zerovector wrote:Hi there,

I have a 3d mesh which is a page and the camera is facing the page from above, so looking down on the page. I want to be able to touch the screen on a mobile device and move the camera only on the y axis and lock x and z. So to allow the user to read up and down the page because you will only be able to view part of the page due to being zoomed in full screen..

Can anyone help me with this, I have tried with onMouseMove which does the touch and mouse click which does it on the page mesh.. But I just want to move the camera up and down the page as you slide your finger up and down.

In other words PAN the screen along x and y with my finger on the mobile screen or a hold down click and move the mouse..

Thanks, maybe useful for others... :)


I have almost worked it out now, I can get the camera to move up and down the page using the swipe of my finger on a mobile device. I am using OSVCamera, but when the camera moves to the top or bottom of the page I cant seem to stop it from moving past the page due to the way the camera moves.. It tweens to a stop and from when my statement tries to stop it.. Its moved more.. So it just never stops in the right place..

I was thinking and tried to make a box with a collision and added a collision to the OSVCamera. But I just could not get it to work. The camera would just push the box out of the way and not block the camera... Any help with this would be best I think than messing with numbers.. Just have a box blocking the camera from moving up any more and the same for bottom of the page..
zerovector
Fresh Boarder
Fresh Boarder
 
Posts: 2
Joined: 2018-07-25 02:19

Re: OnTouch move camera up & down on Y to look up & down on

Postby broozar » 2018-07-30 00:21

hi,

it's quite difficult to help you without any code. here are some general pointers though:

- Y in ShiVa is the up/down axis, so if you want to lock all other axis and then only move the camera along Y, while looking down, you are essentially zooming, is that what you are trying to achieve? Sounds more like a zoom to me...
- you can zoom using changes in camera FOV, no actual camera motion required
- ... but you typed "PAN the camera along X and Y", so which one is it?
- if you want to use motion, then do it with maths, not physics. don't use a collision box. simulating a non-physics object like a floating camera with a physics system just for the movement is unnecessary.
- onMouse... events with touch only work if it's the only thing you are touching. if you need to hold down another key, you need other handlers: http://www.shiva-engine.com/shiva-multitouch-explained/ but since this is a complicated topic to understand, only read that if you are actually in need of more than 1 touch point.
User avatar
broozar
Administrator
Administrator
 
Posts: 4134
Joined: 2007-09-16 10:22
Location: Berlin - Germany


Return to Game programming

Who is online

Users browsing this forum: No registered users and 6 guests