Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,365 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_move is being negative #319544
04/15/10 18:42
04/15/10 18:42
Joined: Apr 2010
Posts: 4
GamerQ Offline OP
Guest
GamerQ  Offline OP
Guest

Joined: Apr 2010
Posts: 4
Hi All,

I'm having some trouble with c_move  and negative values, and I'm hoping this is a really simple oversight on my part because I'm starting to think I'm better off working on my own collision-detection then relying on this inconsistent function.

I made a level in WED with a ball and a paddle (both MDL models) and attached a script with actions for both models, then built the level.  

Paddle Action Code:

action move_paddle()
{
var pspeed = 4;

while(1)
{
If (key_a)  //move left
cm_move(me, nullvector, vector(-pspeed*time_step, 0, 0), GLIDE);

If (key_d)  //move right
c_move(me, nullvector, vector(pspeed*time_step, 0, 0), GLIDE);

wait(1);

}// end while

}// end action


The 'd' key works fine (moves to the right), but the 'a' key does nothing or will randomly move to the right too if I toggle the bbox flag in WED.  I've also tried replacing the pspeed variable with the value "-4" in the c_move function and I get the same results.  Same story with the ball action, won't move if a value is negative.

Most other c_move topics I've seen involve setting one of the _PASSABLE flags but I've tried a few of those too with the same result.

Can anyone help me with this?  There has to be something I'm missing...

-Q

Last edited by GamerQ; 04/15/10 22:36. Reason: Example code correction.
Re: c_move is being negative [Re: GamerQ] #319553
04/15/10 19:50
04/15/10 19:50
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I cant see anything wrong with this code as such, so I think it is just an
"un-expected" collision causing this problem.

As a test, try using all these flags, and it should move fine.
If this is the case, try them one at a time till you find the one that makes the problem go away.
Then you'll know what type of object is causing the problem, and that should point you the the problem object.
Then you just have to decide what to do about it...
IGNORE_WORLD | IGNORE_MAPS | IGNORE_MODELS | IGNORE_SPRITES | IGNORE_CONTENT | IGNORE_PASSABLE


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: c_move is being negative [Re: EvilSOB] #319556
04/15/10 19:58
04/15/10 19:58
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Another thing you could try is this(untested)....
Code:
action move_paddle()
{
   var pspeed = 4;
   while(1)
   {
you = NULL;
      If (key_a)  //move left
         c_move(me, nullvector, vector(-pspeed*time_step, 0, 0), GLIDE);
      If (key_d)  //move right
         c_move(me, nullvector, vector(pspeed*time_step, 0, 0), GLIDE);
if(you)
{   
    toggle(you, BRIGHT|UNLIT|TRANSLUCENT);
    wait(1);
    toggle(you, BRIGHT|UNLIT|TRANSLUCENT);
}
      wait(1);
   }// end while
}// end action


The object it is colliding with should sort-of flicker enough to be seen.
This will work if it is an entity, terrain or model I think.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: c_move is being negative [Re: EvilSOB] #319560
04/15/10 20:18
04/15/10 20:18
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
All you need is something like this(its extracted from a script I wrote for a workshop for kids):

Code:
function fish()
{
	while(1)
	{
		c_move(my, vector(key_w - key_s,key_a - key_d,0), vector(0,0,0), GLIDE|IGNORE_PASSABLE);
		wait(1);
	}
}



I can't see a wait(1); in your code.
If you actually didn't have any in your script, I wonder how it worked, anyway.

Re: c_move is being negative [Re: Pappenheimer] #319583
04/15/10 22:17
04/15/10 22:17
Joined: Apr 2010
Posts: 4
GamerQ Offline OP
Guest
GamerQ  Offline OP
Guest

Joined: Apr 2010
Posts: 4
@EvilSOB
Wow. That flicker/collision thing is genius! shocked I completely forgot that I placed the paddle and ball in a giant hollowed-out cube (model). A simple IGNORE_MODELS flag is all I needed after that to get things working properly, and that was a great example of how the YOU pointer works. Thanks for the help! laugh

@Pappenheimer
Sorry, I retyped the code from memory and left out the wait(1), but the original code had it in there (I'll edit original post). Also, thanks for the c_move suggestion. A slightly modified version of that could come in handy. grin

- Q

Re: c_move is being negative [Re: GamerQ] #319589
04/15/10 23:21
04/15/10 23:21
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Glad to be of help.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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