Vallar's Recent Forum Activity

  • Hey everyone,

    I have a top down game and I have obstacles that I would like to vault over. How do you go about doing that?

    There are barricades in the game that the player creates. Now what I want to do is have the player be able to vault over them.

    Here is what I tried to do:

    1- Create the barricade object.

    2- Create a hidden object called "Vaultable Object"

    3- When player steps on Vaultable Object and presses Space, I stop its controls and tween from Vaultable Object on the left of the barricade to the right of the barricade.

    This works perfectly if there is one barricade only. It doesn't work well with two barricades or more as the picked instance is always the first one created. Moreover, this works along the width of the barricade and not the length, I would like the player to be able to do vault in both direction.

    Here are the events I am using:

    i.imgur.com/yVxvPCp.png

    And while at it, quick question, is there a way to have the player jump in a top down game in C3? Maybe that is a better approach so the player can jump any time they want rather it being context based?

    Tagged:

  • object.lineofsight.hitX & object.lineofsight.hitY will give you the coordinates of the intersected raycast.

    You can also use object.lineofsight.hitdistance if you need a quick measure of the distance.

    I didn't know that. Thank you very much!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I would do this with LOS/raycasting and MoveTo behavior. Bullet at high speeds is too unreliable and hard to deal with.

    Gotcha. Is there any way I can get the contact point of the raycast? Or perhaps get a point on a direction.

    Say, like in the GIF, I have the ball in the middle but tap on the black box. The raycast will detect collision and it won't move. Now if I can't get the contact point of the raycast, is there a way to say something like "Even if there is a collision with the raycast, move the ball X and Y pixels towards the contact point" for example?

  • Here is an example:

    https://www.dropbox.com/s/80h6upcj4mjf9d9/BulletPushOutSolid.c3p?dl=0

    Thanks. Oh, I see now what you mean.

    I tried that. So the "bullet" in my case is the player and I am trying to create a dash behavior. So when I use the method you have right now, I end up with a weird bug.

    Say I dashed towards a box (from the GIF) and say I hit its left side (coming from the left). Now if I click above the top of the box, for some odd reason the player (bullet behaviour object) teleports to where I click. It happens randomly. Sometimes it happens, other times it doesn't. But usually it is when the object is stuck to the box on one side while I am clicking on the side next to it.

  • At speed this high, even with stepping enabled the bullet will not be able to stop exactly at the edge of the solid object.

    You need to add an event that will "push" the bullet out of the obstacle. In a loop move the bullet backwards 1px and check if it's still overlapping the obstacle. When no longer overlapping - stop the loop.

    There may be better ways to do all this, for example with raycasting.

    The speed is set to 4000 which is the same speed in the Step Example in C3. I tried raycasting, didn't exactly work well (unless I did it wrong). I don't fully understand what you mean here with loop move the bullet. Could you elaborate please?

  • Hi everyone.

    I have an object with Bullet behavior (disabled) and another with Solid behavior. I am trying to make the bullet to stop moving when it is touching a solid and never considers moving if it is touching a solid.

    Here is a GIF of the problem:

    i.imgur.com/muMDiao.gif

    The circle is the Bullet in this case.

    So my code is this:

    i.imgur.com/lA4Nk5v.png

    But as you can see from the GIF no matter what, it still goes through the solid if I spam tap.

    I tried having a subevent checking if the bullet is overlapping a solid, it won't register the tap. But the problem then would be if the bullet touched the wall, stopped and now the player wants the bullet to move OUT of the wall, they can't because the tap is ignored.

    Any idea how I can resolve this issue?

  • Here's an example. You would replace the localstorage events with whatever your server uses.

    https://www.dropbox.com/s/3diz2xukc4732zg/LocalstorageSaveArrayExample.c3p?dl=0

    Oh, wow, thank you very much. That explains it pretty well.

    I wish this forums had some kind of kudos system :D. Thanks again!

  • I think I understand...

    Like I said earlier, the simplest way would be to keep your local data in an array. You can get the entire array as a json string by using the array.asjson expression. Send that to the server for storage.

    Retrieve the array.asjson from the server, and use the array load action to get it back into an array, to append and modify as you wish.

    There's no reason you need to convert the array into key:value pairs unless I'm totally missing something, like you needing to modify or access it with a third party program that can't handle json arrays for some reason.

    The other option would be to use the json object actions to set each path, object, and value, then send json.tocompactstring to the server. Then you can retrieve it and use the json parse action to load it up and be able to modify it again.

    I'd think the array method is cleaner/easier though.

    Edit: I can put together an example using local storage as the "server" later if you need.

    Hmm, I think I see what you mean. So the array will be 2D; X say would be an entire order. Then each cell in Y is one of the pieces of the order (sender, ID, description, etc...)? I just need to memorize which cell handles which piece of data?

  • Right, because an array is just a set of values with no object names, you'll need to create object names manually with the json actions manually.

    Although normally you would want to send an array as an array, and object/value pairs as is.

    Is there any reason you need to convert? Anything that can read json should also be able to read json arrays.

    Or I'm still misunderstanding.

    Oh, I don't need to convert. Basically I am trying to create this data structure in JSON:

    Orders:

    --Order1

    --- SenderID

    --- Description

    --- ID

    --Order2

    ---SenderID

    ---Description

    ---ID

    --Order3

    ---SenderID

    ---Description

    ---ID

    User logs in, sends an order and it gets added to that list on the server. Then when the other user logs in, they pull the information and get that list and I parse it to display it in a better way.

    I don't know how to get that kind of result using the JSON object or the Array object personally. I am using the PlayFab plugin which forces me to get all data currently available. Then append the order being sent. Then upload the entire thing (old + new).

    This data isn't global, it is stored per user.

  • If you don't want to use a Json array, then you can manually create keys with the JSON object actions set path, set object, and set value actions. Then the tobeautifiedstring or the tocompactstring expressions will return your json as a string you can send.

    Oh, sorry I think I misspoke. It isn't about what I want. I just don't see how it can be done. Since in my mind the array doesn't take a "key" just the value". So I wasn't sure how to set it up the key/value way so when I am reading back the JSON on the other side I could extract what I want.

  • The array expression Array.AsJSON will give you the array as a string in JSON format.

    I'm not familiar with uploading to a server. Depends what kind of server you are using. If the array isn't too large I imagine you could use a POST link to a php page with AJAX object, and the server can save it to a mysql db.

    Or if you're using something like firebase the plugin can probably send data directly.

    So let me see if I understand correctly, what you're saying is that I should have an Array object, inside that object I'd add my strings (the 4 of them) and then choose the Array.AsJSON and then send it over (I'll be using PlayFab so I am using its plugin for the upload)?

    If that is the case, that would not allow me to create the strings in a "key:value" format from what I understand.

    I'd like the JSON to be structured in a way that I can simply say:

    { orders [ sender: "senderID", description: "this is some order that has some long text description", orderID: 2, recipient: "recipientID" ] }

    So when I receive such a string from client1 on client2 I'd be able to take the data and display it to client2 the way I want.

    Does that make sense?

  • Hey all,

    So I am trying to create this ordering system. Let's say I have 4 textboxes; sender, description, ID and recipient. The first and last one are a random string of characters. Description is a long body of text. Order is just a number (int to be exact).

    However, each user in the game will have a bunch of orders and I need to store that in an array.

    What I want to know is:

    1- How do I turn the values in the 4 textboxes into a JSON (tried to look for it but seems all info is about parsing from not converting to JSON)?

    2- Then how do I add that to an "Orders JSON array" (not sure how that is done) to write it to a server?

    Any ideas how I can achieve this?

    Tagged:

Vallar's avatar

Vallar

Member since 24 Mar, 2014

None one is following Vallar yet!

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies