Energy ray - Dragon Ball Style

Hi everyone,

I’m currently spending time on the BGE, trying to figure out the mecanisms. What I’d like to achieve now is my character to throw something like a Kamehameha, some kind of ray beam that would hit the opponent. But, I don’t have any about how to do it. Should I modelise the beam in another scene and then throw it from an empty ? But, in this case, I’d be like a bullet, which is something I do not want. I wish it to “unfold” with the distance. Should I use the IPO curves ?
Anyway, if somebody can help, that would be greatly appreciated !
Thanks for your ideas !

http://i.imgur.com/JWpvCdT.gif

u mean this ^.^ ?

Exactly ! How did you do it ? ((:

i just used a ray to get the hit position, then u spawn the flash plane into the scene, sketch it from the spawner to the ray hitposition o.o

Actually, I wanted the head of the ray to start from the hand of my character to the opponent ? See ? Exactly like a real kamehameha. You have any ideas ?

sketch it from the spawner to the ray hitposition o.o

so you parent an empty to the hand(bone) and apply rocky’s method.

Yes, yes, I do know that. But, how can it stretch on its x axis ?

Use Python to do what Rocky said - stretch the “beam” forward to the hit point / end (so you’d have to use Python get the distance from the spawning point to the hit point / end). However, it’s also worth noting that:

  1. Kamehamehas are beams, and beam attacks in anime and games usually aren’t instantaneous. In the show, they travel through the air, so you do want something that takes some time to visibly and physically reach the opponent, not a straight ray cast (which is what you’d use for bullets).

  2. Rocky’s method works because it’s in 2D, which means the beam is just a flat plane. That won’t work in 3D; you’ll have to make the beam basically a cylinder, point it to the beam head, and then stretch it from the spawn point to the head as it travels through space. Put a “flash” sprite at the beginning, and you’ll basically have it.

If you need help with Python, you should be able to find tutorials around the Internet. Someone around here might be able to give you a tip or an example blend file, though.

Here made you a basic plane scaler:
scale plane.blend (521 KB)

from bge import logic

def shoot():
    
    #basic stuff
    cont = logic.getCurrentController()
    own = cont.owner
    scene =  logic.getCurrentScene()
    
    #grab laser object
    laser_object = scene.objectsInactive['laser']
    
    #shoot a ray in y direction with a distance of 10 Bu
    to = own.worldPosition + own.worldOrientation.col[1]
    ray = own.rayCast(to, own, 10)[0]
    
    if ray != None:
        print('hit: ' + ray.name)
        
        # add the laser object for 1 seond
        laser = scene.addObject(laser_object, own, 1)
        
        # get the distance to the wall starting from the empty
        length = own.getDistanceTo(ray.name)


        # set the y scaling 
        laser.scaling = [1,length,1]
 
shoot()

Thanks guys ! I’ll work on this and get back to you ! (:

Appreciated !

I tried the plane, it’s great, but it does travel the distance between the empty and the target instantly. Shoud I use IPO curves to make an animation ?
And, why do you take the first column of the matrix to get the orientation ?

Thanks again !

I tried the plane, it’s great, but it does travel the distance between the empty and the target instantly. Shoud I use IPO curves to make an animation ?
no idea what is best for this but i would make a fade in and a scaling animation, and run it with a property. so that you scale the laser to 50 bu at frame 50 to get 50 Bu range max. then add the laser then play the animation.this way you can set the max range trough a property. its kinda the healthbar method.

And, why do you take the first column of the matrix to get the orientation ?

 to = own.worldPosition + own.worldOrientation.col[1]

we grab our location then we want to shoot the ray into a direction (i would atleast).
The orientation.col[1] stand for the Y matrix/vector, in order to shoot to an different location use 0 for X and 2 for Z direction.

you can define the range at the ray variable, the 10 stands for 10 Bu.

Oh, alright. I think I’m using too much MatLab, in which, column always start at 1. :wink: