Help in script! Crashing for no reason.

Posted By: Rohiaw

Help in script! Crashing for no reason. - 06/10/09 10:00

Hey guys. I've recently added an enemy in one of my test games and i have been getting a crash.

I have put an enemy on my level in WED, and attached to it a script that make it turn towards the player and move forward, thus moving towards the player. But i keep getting the crash message when the game starts.

This is my code:
Code:
action enemy_action(){
	VECTOR* dir; // this will hold the direction towards the player from the enemy
	while(1){
		vec_diff(dir,player.x,my.x); // set dir towards player
		vec_to_angle(my.pan,dir); // set the enemy's pan towards it
		c_move(me,vector(3 * time_step,0,0),nullvector,GLIDE); // move forward
		wait(1);
	}
}


What am i doing wrong?
BTW : THIS IS LITE-C NOT C-SCRIPT so do not post up C-Sript codes.
Thank you
Posted By: KiwiBoy

Re: Help in script! Crashing for no reason. - 06/10/09 10:13

Code:
 vec_set(dir, player.x);

                       vec_sub(dir, my.x);

                       vec_to_angle(my.pan, dir);
is one that always works.
Posted By: EvilSOB

Re: Help in script! Crashing for no reason. - 06/10/09 10:17

Also, VECTOR* dir; should be VECTOR dir;(no asterisk)
Posted By: Rohiaw

Re: Help in script! Crashing for no reason. - 06/10/09 10:18

sorry kiwiBoy. I am still getting crashes :'(
even with ur code
thanks anyway
Posted By: Rohiaw

Re: Help in script! Crashing for no reason. - 06/10/09 10:19

WOW. Removing the asterisk worked.
thanks AGAIN EvilSob!
Posted By: Tobias

Re: Help in script! Crashing for no reason. - 06/10/09 10:20

Your code MUST crash because you're using an empty vector pointer (VECTOR*) and not a vector (VECTOR). Read the manual about the difference between pointers and variables.
Posted By: Rohiaw

Re: Help in script! Crashing for no reason. - 06/10/09 10:40

its ok. I know the difference. Just another careless mistake.
© 2024 lite-C Forums