Whats moving the ball?

Talk about making games.

Whats moving the ball?

Postby barney12345 » Sat Aug 29, 2015 2:38 am

Hey guys,
so for the past little while I've been trying to see what game mechanics I can make, eg autolocking systems, ai tennis players, etc, but when I tried to make a simple passing mechanism for a basketball style game, the ball just goes away and glitches. Can anyone see if they can find what's wrong
Cheers, barney
Attachments
ball.zip
(15.78 KiB) Downloaded 145 times
Darth Vader called... he wants his cookies back
User avatar
barney12345
 
Posts: 122
Joined: Wed Nov 07, 2012 6:52 am
Location: A land down under
Score: 4 Give a positive score

Re: Whats moving the ball?

Postby DeltaLeeds » Sat Aug 29, 2015 4:56 pm

First off, your code should be combined into one script editor, I mean, it's kind of a drag to be checking different script editors in draw actor for checking a simple line of code. And anyway, a semicolon (;) should not be used after a } in an if statement. Make your Ball's draw actor script just this:
Code: Select all
if(pick1=1){
    MoveTo("Event Actor", 0.000000, 0.000000, 5.000000, "player1", "");
           }
if(pick2=1){
    MoveTo("Event Actor", 0.000000, 0.000000, 5.000000, "player1", "");
           }
if(pick3=1){
    MoveTo("Event Actor", 0.000000, 0.000000, 5.000000, "player1", "");
           }

Now, what have you done wrong? Why does the ball keep moving?
Checking a variable in if should be done with "==" instead of just "=". = changes the variables into that designed value. So in the above code, pick1, pick2 and pick3 will be made into 1, and so the ball actor will always move to player1. So to change that, just make the = into ==.
Code: Select all
if(pick1==1){
    MoveTo("Event Actor", 0.000000, 0.000000, 5.000000, "player1", "");
           }
if(pick2==1){
    MoveTo("Event Actor", 0.000000, 0.000000, 5.000000, "player1", "");
           }
if(pick3==1){
    MoveTo("Event Actor", 0.000000, 0.000000, 5.000000, "player1", "");
           }

Now, this code will now check whether pick1, pick2, or pick3 is 1. If any of them are 1, it'll move to player1.

Hope I helped. ;)
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron