Would it be possible to implement acceleration at the beginning and declaration at the end of the pinch zoom, so the zooming would feel a bit smoother?
Thank you. Unfortunately, with this version, the camera again tends to shake and fly away completely into a black screen when moving around, zooming, and panning. Zooming in now seems to trigger the character to walk to the point of touch. Panning now randomly stops working when entering a new scene, but when I zoom in, it starts working again.
I also noticed that with the previous version of the script (and this one as well), when I touched the screen with one finger and kept holding it in place and afterward touched the screen with another finger, the camera jumped. The pinch zoom probably causes this? Could this behavior be repaired by setting that once I hold the finger on the screen for a certain small amount of time, all other input is ignored until the finger is released? (set so that the pinch zoom would still work if the two fingers touched the screen in approximately the same moment)
Thanks Chris, it is a bit better now, but the problem still persists in some instances. When i zoom in/out and let the acceleration/decelaration finish the zooming movement, the camera sometimes goes black again. Especially when i hold one finger on the screen and slide another finger over it (or when i slide one finger over, keep holding, and then tap the screen with another one).
Wouldnt it really be better to just completely turn off any other tocuhcreen input untill the first tap is released?
I think this is a case of trouble caused by trying to extend AC's drag camera with additional features, while also looking to add yet more once all were working together.
IMO, it's best to start over with a fresh camera script - and focus purely on getting the input behaviour exactly right. Once it works as intended, it can then be added to with additional features (following the Player etc).
Duplicate your scene, remove the SuperScript, and GameCamera2D Drag, and instead add a new Camera to the scene. To this, add AC's Basic Camera component, as well as the following. Then assign it in the Scene Manager as the default:
This works decently in my own testing, but you may want to tweak it further to get your exact intented behaviour.
Once you have a script that has the exact motion you are looking for, let me know and I can see about re-introducing the other features related to Player movement etc.
Just to be sure I am doing the right thing - I should replace the current camera with GameCamera2D in the Scene Manager, is that right? (then added the new script to it).
Or should I create an Empty and add components: Camera, Basic Camera, and the new script?
When I Zoom in/out and keep one of my fingers on the screen, the camera jumps slightly.
The orthographic size does not fit the screen initially, but once I zoom in, it fixes itself.
Otherwise, the zoom and panning seem to work nicely!
The navigation now works, as well as item collecting. There are a few issues tho:
1) Zooming now sometimes triggers Character movement.
2) When panning, the camera should stay on the spot I dragged it to and not focus back on the character once the tap is released, as it is doing now. It should refocus on the character only after I tap on the Navmesh or a hotspot (see also 4).
3) Moving items from inventory now also pans the camera.
4) Could we modify character movement so it only walks to a spot when the tap is on a navmesh or hotspot? So f.e. when I click the sky, the character does not move at all (now it moves to the closest point on navmesh).
*5) While using the SuperScript, we modified PlayeMovement script by adding a public void ProcessPointAndClick. I assume it should stay there, right?
Could we modify character movement so it only walks to a spot when the tap is on a navmesh or hotspot? So f.e. when I click the sky, the character does not move at all (now it moves to the closest point on navmesh).
Set your Movement method to Point And Click, then under "Movement" settings set NavMesh search direction to Straight Down From Cursor, NavMesh search % to 0, and then Movement method back to None (all in that order).
While using the SuperScript, we modified PlayeMovement script by adding a public void ProcessPointAndClick. I assume it should stay there, right?
Yes - though the latest release makes this change as well.
There is only one slight issue - I have a scene that is bigger than the screen size, both vertically and horizontally, and the character starts at the bottom left corner of it. At the beginning of the scene, the camera should be focused on the character - so basically placed in the lower-most bottom-most corner. But now it is above it, more upwards for some reason. I have a different scene that is larger than the screen size horizontally only, and the character starts on the left, and it works fine.
Could we add an option for locking the camera in the X and Y axes (separately), please?
And I assume the Orthographic size is set to fit automatically, right?
Comments
Replace the script's ProcessClickUp function with the following:
This solves the issue, thank you!
Would it be possible to implement acceleration at the beginning and declaration at the end of the pinch zoom, so the zooming would feel a bit smoother?
https://paste.ofcode.org/qmbBP6yac7TgW7neHxS2EZ
Thank you. Unfortunately, with this version, the camera again tends to shake and fly away completely into a black screen when moving around, zooming, and panning. Zooming in now seems to trigger the character to walk to the point of touch. Panning now randomly stops working when entering a new scene, but when I zoom in, it starts working again.
I also noticed that with the previous version of the script (and this one as well), when I touched the screen with one finger and kept holding it in place and afterward touched the screen with another finger, the camera jumped. The pinch zoom probably causes this? Could this behavior be repaired by setting that once I hold the finger on the screen for a certain small amount of time, all other input is ignored until the finger is released? (set so that the pinch zoom would still work if the two fingers touched the screen in approximately the same moment)
https://paste.ofcode.org/NfN9dyY9T6d3MRVca4wYMp
Wouldnt it really be better to just completely turn off any other tocuhcreen input untill the first tap is released?
I think this is a case of trouble caused by trying to extend AC's drag camera with additional features, while also looking to add yet more once all were working together.
IMO, it's best to start over with a fresh camera script - and focus purely on getting the input behaviour exactly right. Once it works as intended, it can then be added to with additional features (following the Player etc).
Duplicate your scene, remove the SuperScript, and GameCamera2D Drag, and instead add a new Camera to the scene. To this, add AC's Basic Camera component, as well as the following. Then assign it in the Scene Manager as the default:
(Code adapted from here.)
This works decently in my own testing, but you may want to tweak it further to get your exact intented behaviour.
Once you have a script that has the exact motion you are looking for, let me know and I can see about re-introducing the other features related to Player movement etc.
Just to be sure I am doing the right thing - I should replace the current camera with GameCamera2D in the Scene Manager, is that right? (then added the new script to it).
Or should I create an Empty and add components: Camera, Basic Camera, and the new script?
I am using the second option now.
When I Zoom in/out and keep one of my fingers on the screen, the camera jumps slightly.
The orthographic size does not fit the screen initially, but once I zoom in, it fixes itself.
Otherwise, the zoom and panning seem to work nicely!
Let's be sure it's perfect before moving on.
I've tweaked the script above - is it better now?
And now?
Now it works flawlessly! :-)
OK. Let's try this:
https://paste.ofcode.org/tbRqkKEJhGS5Zv4VQXmwEn
The link doesn't work.
The site can be intermittent. Try in a different browser.
Link works now :-)
The navigation now works, as well as item collecting. There are a few issues tho:
1) Zooming now sometimes triggers Character movement.
2) When panning, the camera should stay on the spot I dragged it to and not focus back on the character once the tap is released, as it is doing now. It should refocus on the character only after I tap on the Navmesh or a hotspot (see also 4).
3) Moving items from inventory now also pans the camera.
4) Could we modify character movement so it only walks to a spot when the tap is on a navmesh or hotspot? So f.e. when I click the sky, the character does not move at all (now it moves to the closest point on navmesh).
*5) While using the SuperScript, we modified PlayeMovement script by adding a public void ProcessPointAndClick. I assume it should stay there, right?
Try this:
https://paste.ofcode.org/3a577tTRcGQQWv8LRdb8EqQ
Set your Movement method to Point And Click, then under "Movement" settings set NavMesh search direction to Straight Down From Cursor, NavMesh search % to 0, and then Movement method back to None (all in that order).
Yes - though the latest release makes this change as well.
Thank you, all seems to be working fine! :-)
There is only one slight issue - I have a scene that is bigger than the screen size, both vertically and horizontally, and the character starts at the bottom left corner of it. At the beginning of the scene, the camera should be focused on the character - so basically placed in the lower-most bottom-most corner. But now it is above it, more upwards for some reason. I have a different scene that is larger than the screen size horizontally only, and the character starts on the left, and it works fine.
Could we add an option for locking the camera in the X and Y axes (separately), please?
And I assume the Orthographic size is set to fit automatically, right?