fateriddle Posted November 8, 2018 Share Posted November 8, 2018 Wanna trigger animation when camera move to a certain spot, how? I wanna watch the position of camera every frame, once it gets to a certain point, an animation will trigger. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 8, 2018 Share Posted November 8, 2018 Hi Fateriddle! Here's a playground that does something: https://www.babylonjs-playground.com/#BLAJPA#5 The target is 0,0,0 (set in line 26). The camera starts -100 z-units from target. I slowly move it toward 0,0,0. Watch console. ------------- Notice the distance-measuring in lines 31-33. Vector3.Distance() function is SO handy. If camera is within 1 unit of target, a console.log message is triggered. You could start an animation, at that point. The "0" in line 32... is very important. I am using a terrain-following method to move the camera. The camera moves up/down OFTEN... so it was very difficult for distanceToTarget... to ever be <1 unit. Camera was consistently too far above the target... causing high distance. I needed to force the measuring... to pretend camera was at zero height all the time. This is ONE method for "proximity sensing". There are others, which likely involve invisible mesh at the target, and another invisible mesh parented to the camera. Then you could check for mesh intersections, using one of many methods which are available in BabylonJS. Hope this helps. Stay tuned for more comments from others, and tell us YOUR thoughts... anytime, of course. Party on! GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.