Forum

Object that follows x-y animation & z physics.

25 May 2016 01:43 #9705
Hopefully I can save myself a lot of time and grief by asking this question, which i hope makes sense.

I would like to set an object to follow a predetermined path, with curves, relative to an x-y plane. At the same time I would like it to conform to variable terrain along the z axis, as well as pick up/lose speed on inclines. Can this be done?

I can do a diagram to show what I have in mind, if needed.
25 May 2016 17:15 #9720

I would like to set an object to follow a predetermined path, with curves, relative to an x-y plane. At the same time I would like it to conform to variable terrain along the z axis, as well as pick up/lose speed on inclines. Can this be done?
You want it only in blender then you will bake it to animation or you want it to do directly in the engine wihtout baking in realtime?
Blend4web and that kind of thing.
25 May 2016 21:49 #9730
I want the object/vehicle moving along a predermined path in realtime, with the height of the path it follows user-variable and effects of gravity applied. I guess a baked animation would not be able to be affected by physics. If so, then is there an alternative to using an animation path to set the x-y course for the object?
26 May 2016 15:30 #9746
Hello
You can use the following approach:
1) create a curve loop (red ellipse)
2) animate an empty object on this curve
3) enable physics on the empty
4) enable the Special : Collision propety on the terrain material
5) every frame cast ray downwards from the empty
6) in the ray_test callback function you will get the intersection point between the ray and the terrain surface
7) move your object to the point



But in this case you have to create your own gravity interaction.
Blend4Web developer
27 May 2016 08:15 #9755
Perfect! I haven't worked with rays yet. What would the code for getting terrain coordinates look like?
27 May 2016 14:59 #9757
Here is the example. Import it to your projects.
Blend4Web developer
 
Please register or log in to leave a reply.