I’m wondering how possible it is to achieve something like this
but with a camera path - So when the user scrolls, the camera moves backwards or forwards along the path depending on which direction the user scrolls.
Grateful for any advice, thanks!
Depending on how the path movement is implemented, you can attach event listeners to the scroll wheel events that change the variables that define where an entity should be on the path.
Taking this Camera following a path tutorial, the position of the camera on the path is defined on line 50 and is a value between 0 and 1 https://playcanvas.com/editor/code/438429?tabs=5681693
The scrollwheel event listeners could change that value directly.
I’m pretty sure I have used that same code to enable the camera moving along a path in my current scene.
This is my project: https://playcanvas.com/editor/scene/770032
If I added an event listener into this code, would I have to change any of the other parts of it? Or simply just add the event listener and it would function? I don’t know too much about coding so I would be grateful of any advice Thanks so much
You have two opposing scripts that move the same entity (camera-move and camera-path)
Yes, you will have to modify camera-path script as right now, the movement along the path is time based. You will have to take out that aspect of it and keep track of the percent the camera has moved along the path so you can modify it with a scroll wheel event listener.
yep - camera-move was an initial test that didn’t work out the way I wanted too!
I think it might be a bit beyond me just guessing if you could give me any advice on how I could rewrite the code I’d be really grateful! Thank you