Page 1 of 1
Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 12:57 am
by beginnerirvaz
hey everyone
Before I continue I just want to say thank you to everyone for helping me so far.
I'm at my next hurdle, I have created a ring actor for my player to collect. Each ring is worth 10 points and also shows in a ring counter on screen.
I thought I would be able to clone the ring and have my player collect, however once he collects the first it wipes out all the coins on screen and shows points and count for 1 ring.
Could somebody help me with this please?
Thanks
Irvaz
Re: Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 1:25 am
by skydereign
Most likely your code looks something like this.
player -> Collision with rings -> Script Editor
- Code: Select all
score+=10;
DestroyActor("rings");
If so, you need to use "Collide Actor", instead of "rings".
If though the collision event belongs to the rings actor, then you need to use "Event Actor", instead of "rings".
Re: Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 10:26 am
by beginnerirvaz
Thank for replying.
I've done it this way -
Rings
Destroy actor - script -
Player.points+=10;
Destroy actor - script -
Player.ringCount+=1;
Points and ringCount being actor variables I have assigned a value of points=0 and ringCount=0 to my player
Both the score counter and ring counter textNumber are updated from those variables. I hope I'm making sense, sorry if not,
Re: Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 10:30 am
by beginnerirvaz
Sorry I just noticed my score counter does update with the correct amount of points it's only the ring counter that doesn't. I have 10 cloned rings, all collected and count shows 1.
Thanks
Re: Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 10:31 am
by skydereign
Well, I was talking about the collision code that actually destroys the actor, not the destroy actor event. But so you know, you can remove those two events, and put them into the collision code. Another note, it looks like you made two different destroy actor scripts for a single event. Try to avoid doing that, it makes things harder to look through.
Re: Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 1:17 pm
by beginnerirvaz
I read your last post wrong, I did what you said and makes sense it works great now!
So could I put both those scripts in 1 destroy actor? Or both in player collision? What would be more efficient?
Thanks
Irvaz
Re: Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 2:19 pm
by Hblade
Rings - Collision - Any Side of Player
- Code: Select all
score+=10;
DestroyActor("Event Actor");
Re: Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 4:39 pm
by beginnerirvaz
Hey, I've done what you said and altered my code so my rings and also my health restore items all now hold
Collision - any side of player - script
My ring script is -
Player.points+=10;
player.ringcount+=1;
DestroyActor("Event Actor");
I'm still a bit confused withy health restore items counter. The counter has
Draw actor - script-
textNumber = player.healthrestoreitem;
If the counter shows 3 items are held, I want to click the button next to the counter once to use 1 of those items. If an item is used the count should be reduced. If no items are held you can't click.
The item will do the following -
Player.hp+=10;
Thanks
Irvaz
Re: Problem collecting cloned rings
Posted:
Thu Sep 22, 2011 11:11 pm
by skydereign
So you mean you want something like this?
items_counter -> Mouse Button Down - Script Editor
- Code: Select all
if(player.healthrestoreitem>0)
{
player.healthrestoreitem--;
player.hp+=10;
}
Re: Problem collecting cloned rings
Posted:
Fri Sep 23, 2011 7:09 pm
by beginnerirvaz
That worked perfectly! Thanks for that