Have player pick up coins??

Posted By: gSet

Have player pick up coins?? - 12/16/10 22:24

I know this seems like an absolutely trivial issue, but no matter how much reading I do in the manual or on the boards, or how many different things I try, I can't seem to make this work. All I want to do is make the player able to pick up a coin, such that when the player touches a coin an event is called. I've tried having the coins c_scan for the player, as well as the other way around. I've tried having the coin c_rotate with ENABLE_IMPACT so that the event is called, but the event is called as soon as the coins are created. What could I do to make this work? It should be so simple! If someone can show me what code to use, there won't be any room for stupid mistakes on my part wink
Posted By: Liamissimo

Re: Have player pick up coins?? - 12/16/10 22:40

Code:
action coin()
{
	while(me)
	{
		c_scan(my.x,my.pan,vector(360,360,75),IGNORE_ME);
		if(you == player)
		{
			coins += 1;
			ent_remove(me);
		}
		wait(1);
	}
}



Just take this as action an add it to the coin, coins is the variable vor the coins that the player have, c_scan scans for the player, type in the script of your player
Code:
player = me;



For further questions ask laugh
Posted By: MrGuest

Re: Have player pick up coins?? - 12/17/10 11:22

Originally Posted By: TheLiam
Code:
action coin()
{
	while(me)
	{
		c_scan(my.x,my.pan,vector(360,360,75),IGNORE_ME);
		if(you == player)
		{
			coins += 1;
			ent_remove(me);
		}
		wait(1);
	}
}



Just take this as action an add it to the coin, coins is the variable vor the coins that the player have, c_scan scans for the player, type in the script of your player
Code:
player = me;



For further questions ask laugh
I wouldn't use c_scan for each coin, it'd be better on FPS using
vec_dist(my.x, player.x)
and also in the action have a
while(!player){wait(1);}
otherwise you'll be having a few errors along the way
Posted By: badapple

Re: Have player pick up coins?? - 12/17/10 11:33

you dont need a while loop for such things , especially one running a c scan every frame.

a simple enable impact should do just fine , and its event function can check to see if it was the player who collided

enable impact does not require a while loop running.
Posted By: Liamissimo

Re: Have player pick up coins?? - 12/17/10 11:36

enable impact isn't good for collecting things, you don't want to collide with every coin you are collecting do you? wink
Posted By: gSet

Re: Have player pick up coins?? - 12/20/10 14:29

Thanks a bunch! It seems so similar to what I'd been doing that I'm not sure what wasn't working, but with a couple of slight modifications this does exactly what I needed it to. The way it's set up, when you grab a coin your pos and the pos of all the coins are randomized (I know it sounds like a crappy game... It's for research lol), and so I had to remove all the coins, randomize the position array, and the player pos, and replace them all. I didn't realize that c_scan modified you, so that's actually extremely useful - I'd been using emask.
© 2024 lite-C Forums