|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269475
06/03/09 08:36
06/03/09 08:36
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
The progress is going forward I have now a code that works almost as it is supposed to. I whant a simple code to use so I can understand what I am doing..... smile.... QUESTION: How or where in my code can I reset variabel_1 to 0 again. I have tried several places. And ended up with a if else. So how do I write the else part so the player stops when it reaches the point I have clicked? When I use the code without the else, it goes to that point and stops. But dont react when I click again. So I must reset the varabel_1. Anyone of you have any suggestion on how to do that so it works?Then I will be gratefull!!! And yes I can see that my code isent the best....but it works....Code so far is this for the mouse:VECTOR temp;
vec_zero(temp);
function point_mouse()
{
while(1)
{
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 1000;
vec_for_screen(temp,camera);
c_trace(camera.x,temp,IGNORE_ME);
if(hit.x != NULL)
{
vec_set(my.x,hit.x);
}
wait(1);
}
}
player:action player_mouseAct(){
c_setminmax(me);
var variabel_1 = 1;
VECTOR temp; vec_zero(temp);
ANGLE my_angle; vec_zero(my_angle);
while(1){
if(mouse_left==1){
variabel_1 = 0;
vec_set(temp,mouse_pos3d.x);//mouse_pos
vec_sub(temp,my.x);
vec_to_angle(my_angle,temp);
my.pan = my_angle.pan;
vec_set(temp,mouse_pos3d.x);
temp.z = my.z;
}
if(variabel_1 == 0)
{
if(vec_dist(my.x,temp)<=0.5)
{
variabel_1 = 1;
}
c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
}
else
// {
// variabel_1 = 0;//setting the variable to null?
// }
wait(1);
}
}
Last edited by Eagelina; 06/03/09 08:40.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269476
06/03/09 08:44
06/03/09 08:44
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
action player_mouseAct(){
c_setminmax(me);
var variabel_1 = 0;
VECTOR temp; vec_zero(temp);
ANGLE my_angle; vec_zero(my_angle);
while(1){
if(mouse_left==1){
variabel_1 = 1;
vec_set(temp,mouse_pos3d.x);//mouse_pos
vec_sub(temp,my.x);
vec_to_angle(my_angle,temp);
my.pan = my_angle.pan;
vec_set(temp,mouse_pos3d.x);
temp.z = my.z;
}
if(variabel_1 == 1) {
if(vec_dist(my.x,temp)<=0.5) {
variabel_1 = 0;
} else {
c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
}
}
wait(1);
}
}
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: testDummy]
#269477
06/03/09 08:50
06/03/09 08:50
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
Nope dosent solve my problem. When I set the variabel_1 to the changes where you suggested. The same problems occure....(I can change them as yu did and then it starts to move by it self, and then stops and never moves again) And when I change this part : if(variabel_1 ==0)//deff 0
{
if(vec_dist(my.x,temp)<=0.5)
{
variabel_1 = 1;//def 1
}
c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
} Setting Variabel_1 = 0 ; The player never stops, just "running" around until you click somewhere else...then it goes to that part and keeps "running" never stops. So I must have some kind of "stopping" part..... And I think I must have it in a else part or something like that..... But my brain cant see straight.....smile
Last edited by Eagelina; 06/03/09 08:57.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: testDummy]
#269481
06/03/09 09:05
06/03/09 09:05
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
Tried that one, like this if(vec_dist(my.x,temp)<=(my.max_x + my.max_z) * 1.2) //def 1 But it isent there the problem is . Because when I set it like this: if(variabel_1 ==0)//deff 0
{
if(vec_dist(my.x,temp)<=1) //def 1
{
variabel_1 = 1;//def 1
}
c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
} It does what it is supposed to: Go to where I clicked with the mouse. It does that, and stops at it is supposed to. But when I whant the player to go to the next point, the player turns toward the place I pointed but dosent move..... So it gets to the "turning" code....but not loonger.... So I think I must have some kind of test , to see if the variabel_1 is changed and when I click again, it shall al start over...... like return or something like that we use in other programming languages.
Last edited by Eagelina; 06/03/09 09:10.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269484
06/03/09 09:24
06/03/09 09:24
|
Joined: Apr 2009
Posts: 298 Southern Oceans
KiwiBoy
Member
|
Member
Joined: Apr 2009
Posts: 298
Southern Oceans
|
woops, already solved by testDummy...
Last edited by KiwiBoy; 06/03/09 09:25.
Use the 'manual' Luke, the manual is your friend. 'Self reminder' My WebPage
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: KiwiBoy]
#269494
06/03/09 11:02
06/03/09 11:02
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
@KiwiBoy :
No it isent solved yet..... Still dont get the code to do what I whant.....
I whant to be able to move the player several times , not only one time. ......
Last edited by Eagelina; 06/03/09 11:04.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269504
06/03/09 11:30
06/03/09 11:30
|
Joined: Apr 2009
Posts: 298 Southern Oceans
KiwiBoy
Member
|
Member
Joined: Apr 2009
Posts: 298
Southern Oceans
|
Hi, Untested but should show a clear way out  action player_mouseAct()
{
wait(1);
c_setminmax(me);
var variabel_1 = 1;
VECTOR temp;
vec_zero(temp);
ANGLE my_angle;
vec_zero(my_angle);
while(1)
{
if(mouse_left==1){
variabel_1 = 0;//unset on mouse click
vec_set(temp,mouse_pos3d.x);//mouse_pos
vec_sub(temp,my.x);
vec_to_angle(my_angle,temp);
my.pan = my_angle.pan;
vec_set(temp,mouse_pos3d.x);
temp.z = my.z;
}
if(variabel_1 !=1){wait(1);}
//alternatly; if((variabel_1 !=1) && (vec_dist(my.x,temp) > 0.5)){wait(1);}
if(vec_dist(my.x,temp)<=0.5)
{
variabel_1 = 1;//set on trigger range
c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
}
wait(1);
}
} Hope it helps...
Use the 'manual' Luke, the manual is your friend. 'Self reminder' My WebPage
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: KiwiBoy]
#269547
06/03/09 13:28
06/03/09 13:28
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
No! that didnt do the trick either..... Sounding like a spoiled brat that dont get what she whants.....  ....sorry.... I like all input you all contributes with..... Thanks you so much! the original code works fine, only problem is that it only work one time..... I need it to work everytime I click somewhere I whant the player go.....
Last edited by Eagelina; 06/03/09 13:40.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269553
06/03/09 13:54
06/03/09 13:54
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
heya, try action player_mouseAct(){
VECTOR vec_temp; vec_zero(vec_temp);
c_setminmax(me);
while(me){
if(mouse_left){
vec_set(vec_temp, mouse_pos3d.x); //mouse_pos
vec_sub(vec_temp, my.x);
vec_to_angle(my.pan, vec_temp);
vec_set(vec_temp, mouse_pos3d.x);
vec_temp.z = my.z;
}
if(vec_dist(my.x, vec_temp) <= 0.5){
c_move(me, vector(10*time_step, 0, 0), nullvector, IGNORE_ME | IGNORE_PASSABLE | GLIDE);
}
}
} Hope this helps *untested*
|
|
|
|