Help with my code please

So… im doing a game where you do this… double jump thing… but when you double jump, you leave a trail of energy in the air

i used particule sistem to create this trail of energy and turned into a prefab… then i made an object atached to the character called “spawnpoint” so with scripiting, i could summon the energy prefab to be atached into the spawn point… witch is folowing the character while he is in the air

this was the script

var doublejumpplasma = Instantiate( energyprefab, GameObject.Find("spawnpoint").transform.position, Quaternion.identity) ;
				
			verticalSpeed = jumpSpeed;
			jumping = true;
			SendMessage("DoubleJump", SendMessageOptions.DontRequireReceiver);
			jumpCount ++;

but… when i jump , the particule sistem does not follow me on the sky,… it just gets teleported to my position and then it gets stoped into midair

how can i atach the prefab into the spawn point by scripting?.. and better yet… how can i make the prefab desapear when i land on the ground?

hey i think i can reformulate the question!.. i was looking all over google and i found people talking like this

how to atach prefab to object at runtime… yea ,thats exaclty what i need to do

i even saw some codes…but they dont work

Transform.parent can be used to attach an object to another.
You could also attach the particle system to the object and disable it, only activate it in script if you need it.

oh, thanks! i had figured that there was some code that i just didnt knew the name of… so is … Transform.parent…

do you mind posting an example of how the could would be in this situation?

could it be like this?

Transform.parent ( energyprefab, GameObject.Find (“spawnpoint”).transform.position,Quaternion.identity);

?

Why dont you attach the energy prefab to the character in the position that you want it when jumping (spewing in the right direction) and then call it to emit from script?

Create the prefab,
Attach it to the object at its feet (not to its’ feet, unless that’s what you want)
turn the emitter off
attach the emitter to a script in a variable:
var spawnpoint : Transform;

in script, call for it to emit

spawnpoint.Emit()

http://unity3d.com/support/documentation/ScriptReference/Transform-parent.html

well… that is my problem… i dont know the code to do it so… i dont know how to attach an object to another at runtime by scripting, think you could post a code example?

i tried to do like that link, appels sent… but is not working

also… i think i got another idea… why dont i leave the particule effects attached to the foots of the player since the beggining, but deactivated… and when i doublejumps i turn the particule effects active ?

that spawnpoint.Emit() you posted is to enable the particule animation right?

Hi Warp boy2!

Did u find a solution to your problem?
I think you can use transform.TransformPoint.

[COLOR=#000000][FONT=Times New Roman][COLOR=#222222][FONT=Verdana][COLOR=#006600]// You need to assign an object to this variable in the inspector[/COLOR][COLOR=#006600]
[/COLOR]var someObject : GameObject;
[COLOR=#006600]// Instantiate an object to the right of the current object[/COLOR][COLOR=#006600]
[/COLOR]thePosition = transform.TransformPoint(2, 0, 0);
Instantiate(someObject, thePosition);[/FONT][/COLOR][/FONT][/COLOR]

For more details how to use it just check out the StarTrooper tutorial on Unity’s website.

hey ravinder! i found it ! thanks

but i’ll definitly take a look at that example right now… you know… gather information since im still very nooby

man! i realy think i might use this later!

thanks

oh and appels! sorry i misundestand what you said before, now i got… attach the particle on the body, but leave the emit off… then turn it on by scripting… genious! i did that and it worked

and not only that i learned the code transform.render = true; this will make my life much easier, now im gonna attach a laser gun at the character hand and leave the render off, so it will be invisible… and i will place another model of the same laser gun in the floor… so when the character colides with the laser gun… it will be destroied, and at the same time, the render of the laser gun attached to the hand of the character will be turned ON, then it will give the impression he picked up the thing… cool huh?

The double jump is a separate piece of code…

http://forum.unity3d.com/threads/67240-double-flouble-jump-!?highlight=double+jump

check the link to another guys similar solution (I posted code there too)

The point of that code was to offer the solution for a single jump, where when you hold the button down, you are jumping. then if you let up off the jump button, and press it again, you get a double jump. you can use the code, or modify it, but add the two code lines below.

Another piece of code I wrote was a double jump implemented into the first person shooter.

http://forum.unity3d.com/threads/67826-First-Person-Controller-UT-style

// in the beginning
var spawnpoint : Transform;

// in the section with:
// if we are in the air, and haven't done the second jump, we can. but only once.
spawnpoint.Emit()

BigMisterB thanks alot about the double jump… but i got mine working cool right now… if i had this a couple of weeks ago i would be jumping to the celling of happines because i was getting frustrating at programing a good double jump

well i finaly got it to work, and now when the character double jumps, i do a rocket pack apearing on his back with that (GameObject.render.active = true , and then i make a bursting plasma coming out of the rocket pack with particle.GetComponent(“ParticleEmitter”).emit = true; … looks pretty neat, is a nice double jump (and it has an phisic explanation instead of just jumping again in midair where you usualy can get any impulse xD)

finally when the character meets the ground, the emiter goes false, and so does the rocket pack mesh render… aw man. soo cool

now… talking about your great fps sistem man!.. i’ll definitely use that! because im thinking in a new feature of my game that makes the character aim freely… if you ever played zelda or megaman legends you will get the spirit of my game… is a 3rd person game, but with some weapons you go into the first person view so you can aim precisely… like the crosbow and hookshot and stuff…

so i’ll be adapting your script man =D

edit :

if you’re ok with it