Page 2 of 7

Re: Shooting - How is it done?

PostPosted: Sat Dec 11, 2010 3:46 pm
by Lacotemale
I gave you a +1! :) Thank you so much.

Re: Shooting - How is it done?

PostPosted: Sat Dec 11, 2010 4:02 pm
by schnellboot
no problem ^^

Re: Shooting - How is it done?

PostPosted: Sun Dec 12, 2010 1:46 pm
by Lacotemale
Is there any way to adjust where the bullets are coming from? It would be cool if I could get them to come from the gun! :D

Check the picture! :shock: I can't say where the bullets are coming from at the moment. :D

//Silly picture removed :D

I want to be able to adjust the position of where the bullets come from a bit.

Re: Shooting - How is it done?

PostPosted: Sun Dec 12, 2010 2:49 pm
by schnellboot
Check out the code where the CreateActor function is.
There is something like Player.x,Player.y in the brackets.
Just change that to Player.x+5, Player.y+5 or something.
First do that and then you'll find out another problem.
I'll help you again then if you can't solve the problem yourself.
Good luck!

Re: Shooting - How is it done?

PostPosted: Sun Dec 12, 2010 3:34 pm
by Lacotemale
Awesome! and I even fixed that problem so I can shoot from the gun both ways! :)

I gave you another tip for your hint! :wink:

Re: Shooting - How is it done?

PostPosted: Sun Dec 12, 2010 4:23 pm
by schnellboot
Haha nice work and thanks!

Re: Shooting - How is it done?

PostPosted: Mon Dec 13, 2010 2:27 pm
by Lacotemale
Hmm... I am having trouble implementing a clip system. (limit on bullets for gun)

I tried loads of different ways but none work.

As variable I have:

"clip = 15;"

Inside aimer left click I have:

"if(clip == 0)
{
PlaySound2("data/noammo.wav", 1.000000, 1, 0.000000);
}"

However it still keeps firing bullets. :?

Re: Shooting - How is it done?

PostPosted: Mon Dec 13, 2010 2:44 pm
by lcl
You have to decrease clip every time when you shoot.
Also you have to set it so it creates bullet actor only when clip is not equal to 0.
Code: Select all
if (clip != 0)
{
    //Put the create actor code here.
    clip -= 1; //This decreases clip.
}

:D Helped? :D

Re: Shooting - How is it done?

PostPosted: Mon Dec 13, 2010 3:25 pm
by Lacotemale
Yes I wasn't sure if clip should be clip-- or clip-1 but it was actually clip-= :D

As ye guys should know I do reward you with a +1 for every bit of help I get because otherwise I would be stuck for a very long time. :D

Now I have a more complicated problem... I want my player to changeanimation if the aimer is on the left or on the right of him. Can this be done in GE?

Also is there a way to show a variable on screen? Like an actor that shows the variable on it.

Re: Shooting - How is it done?

PostPosted: Mon Dec 13, 2010 3:48 pm
by lcl
Lacotemale wrote:Yes I wasn't sure if clip should be clip-- or clip-1 but it was actually clip-= :D


clip --; Would have worked too, but I though to put clip -= 1; since it's easier to understand. :D
Lacotemale wrote:Now I have a more complicated problem... I want my player to changeanimation if the aimer is on the left or on the right of him. Can this be done in GE?

Put this code to player's draw actor script editor:
Code: Select all
if (x < aimer.x)
{
    //Put here the animation changing for facing right
}
if (x > aimer.x)
{
    //Put here the animation changing for facing left
}

Lacotemale wrote:Also is there a way to show a variable on screen? Like an actor that shows the variable on it.

If you want to show variable on screen, create some actor with text. Then you can do that:
Actor's draw actor script:
Code: Select all
sprintf(text, "%i, %d, %s", number, number2, sometext);

Where reads now %i, will be placed by integer variable called number.
%d will be placed by double named number2.
%s will be placed by string called sometext.

:D If you need help with understanding this, tell me and I'll help you. :D

Re: Shooting - How is it done?

PostPosted: Mon Dec 13, 2010 4:09 pm
by Lacotemale
Thanks! That aimer problem was really easy. I thought it would need alot of coding.

However the showing variable did not work at all! :(

Re: Shooting - How is it done?

PostPosted: Tue Dec 14, 2010 11:47 am
by Lacotemale
I put this in the draw actor script:
sprintf(text, "%i", clip);


Is this correct? I want it to show the integer "clip".

Re: Shooting - How is it done?

PostPosted: Tue Dec 14, 2010 6:45 pm
by schnellboot
no easier
Draw Actor -> Script Editor -> [show actor].textNumber = clip;

Re: Shooting - How is it done?

PostPosted: Tue Dec 14, 2010 9:17 pm
by Lacotemale
[show actor].textNumber = clip;


What do you mean by [show actor]? What do I have to put there? :?

Re: Shooting - How is it done?

PostPosted: Tue Dec 14, 2010 10:20 pm
by lcl
Lacotemale wrote:I put this in the draw actor script:
Code: Select all
sprintf(text, "%i", clip);


Is this correct? I want it to show the integer "clip".
Make sure to have the code in text actor. (Actor that has text, no animations.) :D
Otherwise your code is right. :D