Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
how to make bullet parabola

guest
Guest
Quote
2021-03-22 12:52:07

hey! i am making a catapult game as coppercube built in shooting feature only allow to shot in different angles but i saw a game on copper cube community that uses function i need

in short i want my bullet (sphere mesh) to fall to ground after some time parabola flight please help


just_in_case
Moderator
Quote
2021-03-22 14:48:55

if you are going to use a physics engine then you can use the ccbSetPhysicsVelocity() with your bullet to make it go up and at the same time change its position.

there are also other multiple ways of doing this but for me, this can be the easy one.


guest
Guest
Quote
2021-03-22 18:18:13

please tell other ways not deep into programming please


DouweDabbe
Guest
Quote
2021-03-25 11:53:50

Maybe you can use g-force in settings of shoot action

Fire with angle 60 degrees or so and g-force 100 or so.


veganpete
Registered User
Quote
2021-03-26 07:52:03

If it was mine you saw (the 4-legged robot-spider game?), the way I did it without coding was:

1- make a sphere (size 0,0,0).
2- add a "rotate" action to the (parent) sphere.
3- attach a textured-billboard (child) to the sphere (parent).
4- move the (child) billboard a distance from the parent (sphere).
5- make a shoot action which fires the (parent) sphere.
6- adjust the "bullet displacement" and "bullet speed" to give the illusion that the bullet is following a parabola.
7- set the "bullet damage" to "0".
8- do not use the "when hit" action - instead make add an "on proximity" event for the billboard (child) so that the billboard kills the enemy when it "hits" them.

*Using this method, to change the angle of attack, you need to adjust 3 parameters -

1- the "bullet displacement" (shoot height)
2- the distance of the billboard (child) from the sphere (parent)
3- the "bullet speed".

Here's a "Parabolic Bullet" ccb game file I made for you to take a look at....
https://drive.google.com/file/d/...


just_in_case
Moderator
Quote
2021-03-26 08:29:13

Use physics if you want, ccbSetPhsyicsVelocity () will provide much better control over the parabola.
If i got time I will try to create it into an action which will allow you to shoot a cannon or parabola. But that will surely require physics engine to be turned on. Physics is easy for such stuff otherwise we can create fake gravity for that the bullet and then move it with a velocity so that it goes in parabola.

Will see what i can do for this or maybe someone who is better programmmer like @smnmhmdy might be already working on something like this🤭😇😇


veganpete
Registered User
Quote
2021-03-26 11:23:55

Agreed. Physics would definitely be a nicer option!

The only problem I found, as a beginner, is that Coppercube's default "shoot" function ignores gravity and physics - it always shoots in a direct line.

As I don't know how to code yet, I used the "rotate" function as a dirty workaround for now ("rotate" and "on proximity" work with "shoot").

If you could find time to make a "shoot parabola", that would be fantastic!


gree
Guest
Quote
2022-12-13 17:55:31

@veganpete I'm trying to create such an effect in WebGL. Due to the missing physics I'm thinking hard about a solution.

Would you mind re-uploading the example you mentioned above? Thank you.


VP
Guest
Quote
2022-12-14 07:54:16

Hi, I have a (partial?) solution for webGL... you can use a particle generator to create the "illusion" of a realistic-looking parabolic bullet.

Add a png for the bullet. Rotate the x axis by 180 degrees (so it shoots downwards, instead of upwards). Set particle emission to 1 particle per second (min and max), set the node to invisible. Now when you shoot, select the particle generator as the bullet. When you test, the particle gen will start each time it's clones as a bullet - you will see the bullet moves downwards as it travels forwards (giving the effect of a parabola).

The problem is that the particle only appears after 1 second. To get round this (see my TankRescueGame), you can simply add a second shoot command.... make a second bullet node (just a simple static node - no particle gen), and set it to invisible. Add a new shoot action at the same time as the first shoot action (so it's shooting 2 bullets at the same time). Set the range of this second bullet and set this second bullet so it disappears after 1 second.

Now when you shoot, the first bullet will appear for 1 second ( and fly straight), the second bullet "seamlessly" appears after 1 second, and travels on an arc. This gives a perfect illusion of the bullet flying in a parabola. *You will need to tweak the "range" of the static bullet node to get the timing seamless (otherwise you will see the 2 bullets).

The issue obviously is that it's only an illusion (the bullet is actually flying straight). The second issue is that the bullet has to be visible for at least 2 seconds before you really notice the parabolic curve (due to the particle generator).

It's not perfect, but will work as a last resort - if you can't find a better solution. This is the option I went for in my game - it was driving me insane - I went through about 15 different methods - all worked to some degree but I settled on this in the end because I only needed it as a visual effect.

Here's the ccb file for you as an example (first file is the gae.exe, second file is the game.ccb source-code).... I think I put the bullet mechanics on the "tank turret" node:

https://veganpete.itch.io/jungle...

I'll keep trying. If I can think of a better method, I'll post it here.


gree
Registered User
Quote
2022-12-14 12:09:30

@VP Thanks for all details. For sure this solution works on some projects. Kinda like your workflow ... sadly it ain't work for this current project I'm working on 'cause I'd need more of a physical parabola.

Currently I'm using a solution without parabola. But the real thing would be great :)

I've read some thread about cannon.js / ammo.js that even they can't simulate it correct - Does someone know some insights?

Thanks


gree
Registered User
Quote
2022-12-14 12:10:17

@VP thanks for sharing JungleTank.ccb - will have a closer look how you did this magic trick :)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact