Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
Move object down after leaving screen
  • Hi

      I have started a simple idea of a character moving automatically across the screen using the animate controller but when the character leaves the screen I would then like it to return back from the left side but lower down again . I have tried the teleport option with the Y axis but whatever value I choose there whether it is a fixed value or * by the Y axis of the self.spatial it does not make any difference.

     Thanks

    TimCS
  • 24 Comments sorted by
  • @TimCS if you want to move an object use the Move action which applies the speed to the linearVelocity value of the object's spatial. When it goes off screen then just change its position to reset it back to the other side of the screen and it will keep moving from its new position.
  • @Lavon

      Thanks for the reply, I since figured out the event part where you put a condition in to wait for the object to leave the screen as I found this from your Hungry Hero tutorial . However whenever I tried to set the position I was not using the move action and so when it reached the end of the screen it continuously dropped down :).

      I will give you suggestion a go as I my other thought was to destroy the object when it reached the end of the screen and then try and re-spawn it at its new position.

    Also if I have the animation in a loop repeat count would this override any move settings or changes I make ?

    Thanks

    TimCS
  • Hi again

     I think I am being thick here (probably because my brain is tired from work) but I have tried the move action after the object reaches the position on the X axis and nothing changes. I have tried just an angle to start with and then I have tried to add to either the spatial.Y or the spatial.position.Y and these make no difference to the objects position. 

    **EDIT**

      had another go at this, could not seem to get it to work with the move action but so far on a test run I have been able to get it to move down using the change property action. Will see if this has the desired effect .
    Please Help

    Thanks

    TimCS
  • @TimCS if you want to change the position of an object you need to use a point object and apply it to the position value of a Spatial. You can do this using the point value type in a change property action or the setPoint( X, Y) helper method in an expression.
  • @Lavon

      I did try to use the setPoint helper but I must have done something wrong for it not to work. However I have got the object to move down now by using the change property action instead


    Thanks

    TimCS
  • @TimCS you must be doing something wrong. Do you want to send in your project via the contact page? Zip it up and send in a dropbox link to it.
  • @Lavon

       I will give it another go as I will probably need to use the move action to increase the objects speed once it leaves and enters the screen .

    Thanks

    TimCS
  • @Lavon

      Still not getting this object to move down the screen with the move action and the setpoint. When using the setpoint I tried the following in the expression part of the direction box:

    If object.spatial.y >= 1026

    move action -> direction : setpoint(-55,self.spatial.y + 30)

    or I have tried

    setpoint(-55,+30)
    and
    setpoint(-55,self.position.y+30)

    So I guess from these attempts I am still doing something wrong

    Thanks

    TimCS

  • @TimCS do you have gravity turned on? Are you using physics based Spatials? If you do and you don't apply a high enough value for the speed then the object may not move. Also make sure your object is movable. Check the type of object on the Spatial. Is it Kinematic, Dynamic, etc.. ?
  • @Lavon

      The object is set as Kinematic as I want to move it across the screen but not been affected by gravity. I am using the physics spatial not the basic spatial. The object can move and the speed is set to 250 which is something else I want to increase each time it exits and enters the screen lower down. I can move the object down the y axis by using the change property against the @spatial.y and apply an expression against it but I presume this can be also achieved by the move action.

      Just to let you know , I basically picked an 80s game to use as a means to learn the software as it is not a very complicated game on face value but when I watched a video of it again on youtube I found that some of the sprite animation could be interesting to try and do with GBS so I may be back with more questions :)

    Thanks

    TimCS
  • @TimCS ok that is the problem them. Kinematic spatials are not affected by environment forces or velocity which the Move action changes. Change the object to Dynamic and just select is Sensor checkbox on the collision shape to have it still respond to collisions but not be affected by them.
  • @TimCS if you don't want it to be effected by gravity just turn off gravity in the Globals tab by setting it to 0. Or dynamically turn gravity on and off by accessing the gravity property on a spatial like this:

    @Spatial.spatialManager.gravity

    gravity is a point object so use a Point object type or setPoint in an expression to change the value.

    You could also counter the gravity applied to an object by putting an opposing value in the Spatial's gravity force property but that may not achieve your desired results.
  • @Lavon

      is this why setpoint is not working ? If so how come using the change property works instead?

      Just changed  the global gravity to 0 but forgot that gravity is needed for the other object that is spawned from the main object which does need gravity to drop down. Will see what difference changing the @Spatial.spatialManager.gravity does for the main object. 

    Thanks

    TimCS
  • @TimCS You can apply gravity to a specific object by changing the gravity force value on the specific objects' Spatial properties.
  • @Lavon

       That is the spatialManager.gravity that you are referring to? not had chance yet to try this but one question how is it that it works when I use the change property action on the Y axis for this object but I cannot yet get it to work with the move action using the same logic ?

    Thanks

    TimCS
  • @Lavon

      Just regarding one of your previous replies :
    do you have gravity turned on? Are you using physics based Spatials? If you do and you don't apply a high enough value for the speed then the object may not move. Also make sure your object is movable. Check the type of object on the Spatial. Is it Kinematic, Dynamic, etc.. ?

    The fact is the object does move across the screen, it simply does not move down by the pixels stated when using the move action. So there is gravity to the object but for some reason the move action does not apply the change of the Y axis. The object is movable because it goes across the screen and is set to Kinematic. 

     On the matter of the object, I am actually using the predefined plane sprite object from GBS and move it across the screen and have got it to move down, as stated before , using the change property against the @Spatial.y property. 

    Thanks

    TimCS
  • I have created a new project now just to test the move action with a square object. So far I have got the object to move down with an event on mouse down but the move action is set to an angle of 90 . 

     However if I apply ,as per my existing project (mentioned on my first post), an animation to move the object across the screen using the @spatial.x property and apply a rule that when the @spatial.x >= 800 (the edge of the screen) the object simply stops at that point.

     Does this mean that the animate action / method cannot work with this logic? It does however appear to work if I move the object down with the property action where by change property @spatial.y (expression) self.spatial.y+30 .

    Hope this makes things clearer in what I am trying to achieve 

    ** EDIT **

     On further testing I have found that using the interpolate action to move the object across the scree allows me to then move the object down the screen with the move action with a value of 10 or 20 which is about right for what I am trying to achieve. As this is the case, does this mean that the animate property / method does not work with the move action ?

    Thanks

    TimCS
  • @TimCS the interpolate action can be used to animate a number or point value from one value to another over time. The Move action moves an object using the velocity property on the Spatial.
  • @Lavon


      Okay, what about my other question on why does the animate method not work with the move action but the change property on the objects @spatial.x does.

    Thanks

    TimCS
  • @TimCS once again, the Move action changes velocity. Kinematic objects do not move when their linear velocity is changed. However you can explicitly move a Kinematic object by changing its x and y position.
  • @TimCS the best way for me to diagnose your specific issue is to just zip up your test project and send in a dropbox link to it via our contact form.
  • @Lavon

     Please understand that I am learning how to make games for the first time and finding it very tricky at the moment. I only learn by trial and error and although I have read through your documenation , I found it not for me . 

     I did go through your guides and these have taught me some of the user functions that I have placed into my trial game but I did try and move the x and Y position from the move action on both projects with little success. What I have found is as I stated with how I have moved the object so far with both animate and change property on the Y axis and using the interpolate with the move action.

     To be honest as I have got it moving in either of the above ways , I do not want to bother you anymore on this matter. I am currently trying another part of the project at the moment which is spawning one object,multiple times, across the X axis by the width of the object. 

    Thanks

    TimCS
  • @TimCS I completely understand your learning and I want to help as much as I can. I've explained what may be going on with your scenario but I'm flying blind here. I need you to help me to help you. The best way for me to diagnose why you may not be seeing your object work as you expect is for me to take a look at how you have your project setup. You can send it in via the contact link.

    This will give me the best opportunity to help you. There may be a bug on our end as well which needs to be fixed if you are setting everything up correctly and things are just not working. I can't determine this without you sending in the project.
  • @Lavon

       Okay I understand I will be sending it soon. Not sure if I have a dropbox account so I am trying to attached it to the contact page instead.

      If I am unable to send the attachment this way I will look into using the dropbox option.

    ** EDIT **

     Sent as a link via dropbox hope I have done this right :) 

    Thanks

    TimCS

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Tagged