Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (lijoyi2011), 1,034 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help in script! Crashing for no reason. #270846
06/10/09 10:00
06/10/09 10:00
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
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

Re: Help in script! Crashing for no reason. [Re: Rohiaw] #270851
06/10/09 10:13
06/10/09 10:13
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline
Member
KiwiBoy  Offline
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
Code:
 vec_set(dir, player.x);

                       vec_sub(dir, my.x);

                       vec_to_angle(my.pan, dir);
is one that always works.


Use the 'manual' Luke, the manual is your friend. 'Self reminder' smile

My WebPage
Re: Help in script! Crashing for no reason. [Re: KiwiBoy] #270854
06/10/09 10:17
06/10/09 10:17
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Also, VECTOR* dir; should be VECTOR dir;(no asterisk)


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Help in script! Crashing for no reason. [Re: KiwiBoy] #270855
06/10/09 10:18
06/10/09 10:18
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
sorry kiwiBoy. I am still getting crashes :'(
even with ur code
thanks anyway

Re: Help in script! Crashing for no reason. [Re: Rohiaw] #270856
06/10/09 10:19
06/10/09 10:19
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
WOW. Removing the asterisk worked.
thanks AGAIN EvilSob!

Re: Help in script! Crashing for no reason. [Re: Rohiaw] #270857
06/10/09 10:20
06/10/09 10:20
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
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.

Re: Help in script! Crashing for no reason. [Re: Tobias] #270861
06/10/09 10:40
06/10/09 10:40
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
its ok. I know the difference. Just another careless mistake.


Moderated by  HeelX, rvL_eXile 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1