Forum

How to control speed and direction of a moving object?

02 February 2016 03:03

I think it is a wonderful starter project idea. There is no serious flight simulators of any kind yet on b4w. So it will be really interesting for us to keep track of your app and help to solve problems which you will face
Thank you so much for the support!
02 February 2016 11:08

Regarding my larger objectives with this, I want to accomplish a few different things in a flight simulator game:

1) Planes should fly (Sounds simple, but I think it will be quite tricky. Evgeny has offered me some advice, but I'm still too much of a newbie to implement it.)
2) The planes should be able to shoot missiles and fire machine guns. Experimenting with methods for doing this was the purpose of this thread.
3) Missiles and other weapons should cause damage. I haven't reached this point yet.
I have an advice for you!
You can start from simpler app that can be made using logic editor without going crazy. Runner arcade mechanics comes to my mind. You can for example divide screen in six areas and move your plane/spaceship between them, fire missiles by clicking viewport aligned buttons (see b4w 15.12 features). There is excellent example of similar mechanics in our new year contest entries:
https://www.blend4web.com/en/forums/topic/1275/?page=1#post-6423
You will be able to focus on things like missiles animation, their interaction with targets and overall game look. And the final app will be solid and attractive itself.

After that you can begin to add freedom to your game using already made templates. We can provide support in adding JavaScript coding. Our engine apps structure is rather straightforward and clear, so even people who not familiar with programming can learn it quickly, especially if you understand logic trees tricks. Of course if you are interested in it!

Again it is just my vision of convenient and enjoyable way of developing your idea
Blend4Web Team - developer
Twitter
LinkedIn
02 February 2016 15:54
You might want to look at my script is this file. It's really BGE i'm planning to make it in Blend4Web but you got like the basic algorithm.
I'm quite sure most of this can be done with logic nodes.
The car flicks a bit. It seem to be due to the table material. Just delete it if need be.
03 February 2016 17:06
@Konstantin Khomyakov Thank you for suggesting this idea! Let me see if I understand correctly…
You can for example divide screen in six areas and move your plane/spaceship between them
Do you mean that the plane could be moved to each of the six corners of an invisible cube (in front of the camera)?

I will surely need Viewport Alignment for this and other projects too, so thanks for telling me what that feature is called and where to find an example.

I'm still exploring the possibilities. One thing is for sure - there's no getting around the fact that I need to learn to set up first-person controls sooner or later. I feel that I really should face this, and overcome my aversion to coding.
In any case am curious to learn more about the solution you have suggested.

Another idea I had, since there are no aircraft presets yet, is that maybe I can sort of hack a watercraft setup into working without visible water under it - maybe parenting a block of some kind of "fake" water to it to get it moving through the air. But I haven't even made a conventional watercraft yet, so I am getting ahead of myself.

@LukeVideo
Thanks for offering your .blend to study. I have never used the BGE before, so I'm not even sure where to start. I pressed 'P' and got the car to move using the arrow keys. I couldn't figure out why it disappears sometimes, or why everything is scaled up so large (scaling it down made the car disappear even more easily). Studying the BGE in order to learn B4W seems like the long way to do it, so for now I think I'll just focus on B4W. I appreciate the gesture though.
03 February 2016 18:53

Do you mean that the plane could be moved to each of the six corners of an invisible cube (in front of the camera)?
You can for example use set of viewport aligned empties and Move To to relocate your aircraft
Blend4Web Team - developer
Twitter
LinkedIn
03 February 2016 23:57
Yeah. If you had known a bit of BGE it could of made sense. I am not quite sure what you are planning to do but you will need some JS if you really want damage and things like that in your scene. The main issue with the node editor in mys opinion is that is cant sens collision or read external variables. The good thing is that it is quit easy to get things done in JS. I am planning on porting a few BGE experiments i did in Blend4Web so i hope this will give me enough skills to be of help!

Luke
16 February 2023 00:00
It seems like a long time ago that the last people wrote in this forum for support. I hope at least somebody reads this.. I'm writing a configurator for furniture. I need two buttons on the sides that are supposed to operate like sliders. I've written all the basic logic (working independently from b4w) and it works (for that "sketch" I've used .svg-images as buttons) . Now I'm working on the 3D implementation. For several reasons it would be nice to have 3D Objects as buttons. The only problem is, that my 3D-buttons are sometimes pushed partly or fully out of the viewport, when I change the aspect ratio of the browser window. Viewport alignment seems to be the perfect solution at first. I've parented my buttons to emptys which are parented to the camera and then I aligned the empties with the viewport. Concerning the positioning, viewport alignment is working like a charm. The buttons appear just perfectly where they're supposed to do. However viewport alignment seems to fix them permanently. I've tried to move the empties vertically via
m_trans.move_local(empty, 0, 0.2, 0);

As I said before, they're meant to work like sliders. Unfortunately nothing happens. I doubt that there's any mistake in my code. Because as soon as I uncheck the Viewport Alignment checkbox in Blender, my code moves the empties again without any problem. However, the buttons then again don't stay in the viewport.
It would have been nice to have 3D Buttons, but not necessary. So I've used svg-images as buttons again and it works. Anyway, it would be nice to know if there's a workaround. Is there any way to align 3D objects with the viewport but not permanently fix them absolutely?
 
Please register or log in to leave a reply.