Jump to content

Malaka135

Registered User
  • Content Count

    21
  • Joined

  • Last visited

Everything posted by Malaka135

  1. NOTICE : I am including images & gifs in this tutorial but I reduce usage of visual aids as we progress down the steps. As you perform certain steps such as placing tiles and accessing menus, I will assume you understand that step and won't clutter this tutorial with too many visual aids. Sorry ? Game Logics Required : Spawn Point - Player needs to spawn somewhere ? Player Role - To handle Player OnConnect & OnDisconnect Global Storage - To store our connected Players Custom HUD - To draw the speed Time Trigger - To calculate and update the speed 1st Step - Adding our Game Logics : Go ahead and place down one of each "Required Game Logics" listed above. We will work on them one by one. Spawn Point should be already placed down by default. If you do not have one, just place one down. 2nd Step - Configure our Global Storage : We don't need to touch any of the properties aside from it's scripting and name. Just make sure "Enabled" is also checked. I named mine "Connected_Players" since we are using this to store our connected players. When you click on "Edit" for the Script, it will bring you into the scripting window. On the left side you will see all the available tiles. We are only interested in VARIABLES. Click on VARIABLES. You should see on the right side a button titled "CREATE NEW VARIABLE". Click that. A new window will appear labeled "CREATE VARIABLE". We want to name this something that would describe it's purpose. In this case, I named mine "ARRAY Connected Players". It is IMPORTANT to check "Array" since we want this global storage variable to store multiple objects. Go ahead and click "Confirm" to create our new variable. You might be wondering, "What is an array?". Essentially an array is a list of items which each item has a corresponding Index. Index always starts at 0 so if we have an array with 5 items inside, the size of the array is 5, however the 5th item in the array will be Index 4. This is because the first item is at 0, the second item is 1, the third item is 2...and so on. 3rd Step - Configure Player Role : This isn't important, but I went ahead and named our Player Role game logic to "Player". Please ensure that "Spawn Place" is setup. If not, click on that little dropper and then click on our spawn point to link them. Make sure "Enabled" is also checked. We also want to edit the script for this game logic, so go ahead and click on "Edit". Just like our previous step, we want to take a look on the left side and search for EVENTS. Click on EVENTS to see what kind of events we can handle with this game logic. We are only interested in ON PLAYER CONNECTED and ON PLAYER DISCONNECTED. Go ahead and drag each one to the right into the empty space. We now have two events we want to handle. Starting with ON PLAYER Connect, let's add that player into our Global Storage variable we made in Step #2. Under ARRAY, we want to find a script tile labeled PUSH array. Go ahead and drag that just underneath our ON PLAYER CONNECTED tile. This should link them together like a puzzle. PUSH essentially adds a new object at the end of our array. This tile has 2 empty slots which wants to accept: Array and Object. Under VARIABLES, you should see THIS, Connected Players(if you named your global storage to this), GAME, and GAME SET. We want to click on Connected Players(or whatever you named yours). You should see two tiles: The black tile with two horizontal bars sticking out the left side is our array we made earlier. The blue tile which says "SET" is used to overwrite/store our variable. Since PUSH automatically saves the array, we are not interested in the "SET" tile for this example. Go ahead and drag the black tile into the matching empty slot labeled "Array" in our PUSH. This is to tell PUSH to store whatever object we give it into our array. Object is still empty, we want to PUSH our Player into our array. You might be wondering, where is "Player"? Player is provided to us by the ON PLAYER CONNECTED event tile. Go ahead and drag the red tile PLAYER into our empty slot labeled "Object". What we just accomplished was setting up a script to add our players to our array of connected players. This is very important for a later step so we can point to our players. Lastly, we want to handle ON PLAYER DISCONNECT. Just like we put players into our array on join, we want to remove them from our array when they leave. Under ARRAY, look for the SPLICE tile. Go ahead and drag that underneath our ON PLAYER DISCONNECT tile. This tile takes in 3 tiles: Array, Index, & Count. This tile will essentially remove an object at the index we instruct it to. Instead of having to click on VARIABLES again to find our array which we already placed, we can copy it by dragging it while holding down CTRL on our keyboard. Go ahead and supply SPLICE with our array. Now we need to tell it the Index and Count. Index is the number corresponding to our Player we want to remove and Count is how many objects we will remove starting at the Index. Go ahead and set Count from 0 to 1, since we only want to remove one single Player from our array. Index is a bit tricky because we don't know where our PUSH tile stored the Player in our array. Especially if we have multiple players, we wouldn't know who is what at what Index. Using the INDEX OF tile found under ARRAY, we can search the array and retrieve the Index of our disconnecting player. Go ahead and drag the INDEX OF tile into the Index slot of our SPLICE tile. Now CTRL + Left click drag our array into the empty Array slot of our INDEX OF. Lastly we need to supply INDEX OF the Object it needs to search with. Go ahead and drag Player into this empty slot. Our script should look like the image below.
  2. Malaka135

    The next big step for Ylands

    I can agree. I started this game when I saw it pop on Steam as an advertisement during the big December release. The exploration was the main thing I saw in the teaser video and it drew me in. I picked up the editor real fast and just had idea after idea of doing things so I began my first game with the idea of potentially making some coyns in return for my effort. I've done server hosting in Gmod which I can see Ylands providing a similar massive list of custom servers/gamemodes to play. The dwindling playerbase is making this seem farther out of reach. I do think perfecting Exploration would bring more attention to this game. The most complaints I hear about this game from being in different discords is always something regarding exploration. Personally I don't do exploration as I went into the editor, but I do talk with many players and this is the concern they all seem to share.
  3. Malaka135

    Comments in Editor

    This one should be easy to implement. Can we just have a tile dedicated to comments? Maybe even be open/close-able with a +/- or chevron so we can hide/show the comment. It's starting to get hard organizing and remembering what each thing does in a large projects and comments are a must in coding, they should be also here in the tile scripting
  4. It would be nice if the Interior lighting effects would show up if the Player's camera is within the zone. Currently it seems to only work when the player physically enters the zone. If possible, can we set it to also detect and activate the effect when the camera inside the zone is also enabled and active. Current workaround is teleporting the player inside the Interior game logic zone.
  5. I was trying to devise a way of showcasing different vehicles to choose from and set a simple rotation animator on a vehicle. I had to set the vehicle in a Group to get the "Animated" checkbox to appear for it. It works fine when testing Animation through editor using the F7 command, however when testing it live in game. The vehicle teleports to either 0,0 or the corner of the abnormally shaped green wireframe of the "Group" box. I tested a new vehicle by just placing the chassis down and immediately when creating a Group, the green wireframe box seems to stretch to 0,0 of the world.
  6. Malaka135

    Collision Detection

    My current alternative is just setposition/setrotation on vehicle but since its constantly moving, it doesn't trigger properly. Vehicles are already wonky as they are so doing a collision detection like this just failed horribly. It is also very inconsistent, sometimes it'll trigger when the front or wheel of the vehicle enters the zone, sometimes it only triggers when the center of the vehicle enters. I don't quiet understand fully myself how it operates but it can't work for me as it is since different vehicles have different sizes, hence I can't fine tune the zone sizing to get it to trigger only on collisions. Large vehicles would hit before their "point" hits the zone and smaller vehicles will trigger before even colliding.
  7. Malaka135

    Collision Detection

    Any way to add a way to detect collision between two entities? Such as in the event listener. Regardless of speed, just the fact that two objects touch each other. I want to be able to handle two vehicles hitting each other or a vehicle hitting a wall and detect it. The alternative of using triggerzone or raycast right now is too complicated and unreliable.
  8. That looks amazing. I wish I had building skills like that
  9. AI/NPCs have trouble navigating/pathing indoors. If the floor that they stand on is made of blocks and not terrain, they don't seem to follow players, become aggressive, loiter, etc. Their aggressive "exclamation marks" feedback would be very random and they may pace irregularly or spin in circles, however it is not normal AI behavior. Thanks to the P1 community we found out they do work on welded blocks, but if the blocks are not welded together, AI pathfinding is broken.
  10. Malaka135

    Monitor Projectile

    Are you trying to control an item that can be already thrown like grenades? Or are you trying to script your own throw? If you are making your own Entity template and creating a custom throw. Then you need to handle when the "throw" will occur. Like the player clicks LMB. You'll have to setup custom controls for that. And setup an event listener to listen for custom control from player. In there you will be given the player object so you know who is throwing. You'll also have all the options given to you by the throw tile itself. On entity hit returns 2 values. Where it hit and what it hit. In this case Entity can also be the player which was hit. Does this help at all? I am being brief. Or please rewrite your question to be more clear.
  11. Malaka135

    Mystery related question

    I found a plank in the water once. My silly friend picked it up and when he dropped it again, it didn't float and went to bottom. So we lost the location to confirm what it may have lead to. It is also a sharegame, so I don't know how to take the world into editor and just find out myself. Otherwise, so far I didn't find anything crazy aside from some locked chests with keys I guess I need to find elsewhere. So maybe that is a mystery? There was a map but I couldn't figure out if it was just an item for fun or if I can actually use it. Edit: I brought an exploration map into editor and found an underwater glass structure with some stuff in it. Is this the lab your referring to? Edit: Flying around in editor. I did find a couple underwater secret structures such as ship wrecks, plane crashes, submarine wrecks, even some stone ruins with statues. Is that the Atlantis mystery? I don't know. I didn't see any special items around it.
  12. Malaka135

    Can my buddy build within my barrier?

    If you made the game as a sharegame, I don't think its possible. If you made the game locally then you can. You just need to load into Editor. Hit Create New (We won't be saving a new one so it doesn't matter) On the top left you will see the three horizontal bars followed by EDITOR. That's your editor menu. In there go to OPEN, and you wanna see your games not scenarios, so click on Games on the bottom. You should see your game file in there. Select it and click open. Now find your barrier, select it and delete it. Make sure to hit save too. If your barrier isn't on the spawn island, you can use GO TO in the EDITOR menu to just move to your island faster. Manually flying there in editor is just way too slow.
  13. Sorry for late response. I tried out my idea live and kinda got it to work. I'll show you what I did and you might have to edit it to work with your game. First, I set a persistent variable to store the player's coordinates under Game Settings -> Game Storage I named it disconnect_Position and it is Vector type. I placed down a Player Role so I can handle the OnConnect/Disconnect and I also handle my global storage array of "Connected Players". You'll probably want to do the same if you don't have one already. Its easy, just place down a global storage and create a new variable under Variables. It must be an array. So when they connect, we get the value disconnect_Position to set their new position there. onDisconnect, I actually move their body to the Reference Point 1 which you will want to make and put it somewhere safe. This will be were all the bodies will begin to pile up. I set a Time Trigger to just constantly store the player's position. It is set to 1 sec interval. It loops through all players and set's their disconnect_Position value to their current position. Note* : I tried to avoid using the timer and just store their position on the onDisconnect, but it just wouldn't work. I guess the player already disconnected and the position of get position entity just returned 0 always. So instead I store it live with the timer when I know the game can properly still get their position. There might be a super rare chance that the timer might store their last position just as they disconnect as the safe zone. I doubt this will occur since the timing must be perfect. BUT since it is a possibility, it might be a good idea to setup a triggerzone to teleport them out of the safe zone to protect the bodies of the disconnected players. I hope this helps or at least guides you in the right direction.
  14. Malaka135

    Throw a ball - how to?

    GOOD NEWS!....kinda I figured out how to set direction for aim. Just not up/down but it will throw it in the direction your facing. I found this out from here https://math.stackexchange.com/questions/180874/convert-angle-radians-to-a-heading-vector and thanks to SouLSeuPai from the P1 discord for helping me learn google is still a thing. Basically GET ROTATION entity(Player) returns a Vector (X,Y,Z) with Y being our heading. 0-360 in relation to the world. Direction of the THROW tile wants a vector as well. It's kinda weird to explain but maybe this image can help. Think of it as when your facing forward from spawn, your heading is 0. So if we get the COS of 0, we get 1 SIN of 0 is 0 So if we think of these as plotting them on the graph above, let's image our Y axis is Cos and our X axis is Sin. Facing forward with an angle heading of 0, we get (0,1) Now if we turn 90 degrees to the right, our heading is 90. Cos of 90 = 0 Sin of 90 = 1 So Y axis, go 0 points | X axis, go 1 point. If we plot that on the graph, it points us to the right. So to translate this into Ylands, we need to give THROW a Direction vector: X is gonna be our SIN result Y is a bit weird(I'm still learning this). Think of 0 being straight forward, anything closer to positive 1 is gonna be upwards with 1 being straight up into the sky. Any value approaching negative 1 would be going down with -1 being straight down. Z is gonna be our COS result So we get the Y vector of our GET ROTATION of player. Apply SIN or COS and throw that into the vector values for direction. Lastly, Speed. I don't fully understand this either but the higher the number, the farther it throws it and the faster it throws it. EDIT, I forgot to mention. I changed the +2 to a +1 for Origin so it throws kinda from the hands instead of above the head.
  15. Malaka135

    Throw a ball - how to?

    Unfortunately I cannot figure out myself how to "aim" and instruct the ball where to go. But at least I think I can get you started. First to handle the LMB click, you need to create a Custom Control. You can find that under EDITOR -> Game Settings -> Custom Controls On the right side you see the "?" in a box, kinda looks like a key on your keyboard, you can define inputs as triggers. Since you want to use LMB, that is already setup, so you wanna go to the finger touching the circle one. That is actions. Create a new action, set Active to off. Name it whatever you want. Try to keep the ID something easy you can remember like "throw_cannonball". Set trigger type to tap. By default it is set to RELOAD, click the "SET" button and select PRIMARY ACTION (LMB). If you don't see the list, click on default top right. Show hint and hint just decides what shows up on the bottom right side of the player's hud, I guess this is preferred to be setup. Event Listener for activating the Custom Command we just set to only work with cannonball active in hotbar. Script for this event listener We need another event listener to handle the new Custom Command Script for this event listener It seems like throw likes to take a Entity template only, so I just threw one down and a cannon ball next to it. Linked them with the little dropper. I added +2 to the Y of the Origin so the cannon ball doesn't just spawn right in the player and "hits" the player which is spawning it. Direction is what I cannot figure out myself. Hopefully this helps you out a bit.
  16. I recently discussed this with someone in the P1 discord. They asked the same question. Disclaimer: I haven't tested this yet but I think it should work. My idea on this was to handle it using the ON PLAYER DISCONNECT tile. Their body should be movable using the SET POSITION tile. Just move their body to a safe location and store their position before the move into the persistent game variable. ON PLAYER CONNECT, you can just SET POSITION back to that position you stored.
  17. Malaka135

    Speedometer Tutorial & Car Chassis' Top Speeds

    VEHICLE TOP SPEEDS Car Chassis 1 Engine - 477.5 2+ Engine - 1084 Large Car Chassis 1 Engine - 139 2 Engine - 594.5 3+ Engine - 941 Race Car Chassis 1 Engine - 812 2+ Engine - 1839 Off-Road Car Chassis 1 Engine - 477 2+ Engine - 1083 NOTES : The speeds are calculated using the script explained above. I am rounding off to the nearest 0.5 Car Chassis and Off-Road Car Chassis are almost identical, however Off-Road is very slightly slower. Large Car Chassis is the only one that benifits from a third engine. No difference found between Steam vs Ylandium engines.
  18. Malaka135

    Speedometer Tutorial & Car Chassis' Top Speeds

    4th Step - Build our Custom HUD : We want to be able to display information to our players. We can do this by using the Custom HUD game logic. Make sure the Custom HUD's "Enabled" is checked and also "Visible To New Player"(not sure if necessary but doesn't hurt to have it on). We won't be scripting for this one, instead we are interested in the "Edit" button of USER UI. Click that. You should see something very familiar. This is our HUD. On the top right we are presented with 3 possible items to add to our Custom HUD. We are only interested in TEXT boxes so ahead and click it once. I won't go into much detail here about designing HUDs and various options, we are just interested in the ID/NAME. Go ahead and drag the newly created box wherever you want onto the screen. The important step is to name our new TEXT box something we will recognize. For mine, I named it "TXT_SPEED". Since our speed can potentially be a very big number, and we wouldn't want to run out of space, I'd recommend changing the Width & Height to enlarge our TEXT box. I personally set Width to 500 and Height to 100. I also set SIZE to EXTRA and changed the color to red. What you do with your HUD is entirely up to you. Feel free to customize it however you'd like. Go ahead and clear the default "text" since we want it to be blank initially. We are going to change the text as we refresh the HUD using our timer in the next step. 5th Step - Configuring our Timer Trigger to Calculate Speed & Refresh our HUD : We want to update the HUD and also calculate our speed to set the TEXT box we made earlier The properties found in our Timer Trigger are very important. Since we are looking for a fast refreshing HUD, we can set TIME to 0.03. This is the lowest number allowed at the moment. TYPE should be set to DURATION IN REAL TIME SECONDS. REPEAT COUNT should be set to -1. And also make sure Enabled is checked ? TIME is how long the timer would wait before triggering. This is in seconds, so you can imagine 0.03 is very short period of time. We want this because we want to trigger this timer as many times as we can within a second. REPEAT COUNT is how many times the timer should run. Since we want this to run infinitely and never stop, we can use -1 to instruct it to repeat indefinitely. Let's go ahead and jump into Scripting so we can now tell the timer what to do. Under EVENTS, we are interested in ON TRIGGER. This means that every 0.03 the Timer Trigger will....you guessed it... TRIGGER! A important thing to know is HUD is drawn and refreshed independently for each Player. This means we need to update each Player's HUD separately. We can achieve this easily with a loop. Under LOOPS, look for FOR EACH. Go ahead an drag that under our ON TRIGGER tile. We have one empty tile to supply for our FOR EACH tile, go ahead and put our connected players array. So the idea here is FOR EACH Item in our array, this will run the script tiles we place inside the FOR EACH tile. Go ahead and click on Item so we can rename it to something nicer like "Player". Now we only want to update the HUD on our Player only IF they are in a vehicle, otherwise we wouldn't want to run any code at all. We can achieve this using the IF tile found under LOGIC. This is what we call an IF STATEMENT. Notice the empty tile to the right of IF? That is our condition. If our condition is TRUE than the code inside our IF statement will run. If it is FALSE, then it won't run. TRUE & FALSE are booleans but we don't need to worry about that. For now, just know that anything put into the IF statement would always return true unless it is 0 or empty. For our case, we want to make sure our Player is in a vehicle. We can do this using the GET CONTROLLED ENTITY tile. Did you know you can search tiles? Well this will be useful for this step since finding our tiles might be a bit hard. You can search by typing into the "TYPE HERE" field located on the left side of our script window. Once you find GET CONTROLLED ENTITY character, go ahead and place it into our condition empty slot of our IF statement. The character we are getting the controlled entity of is our Player. If you renamed Item to Player, you would find that above in our FOR EACH tile. Go ahead and drag that down into our GET CONTROLLED ENTITY tile. You might be wondering why we are using GET CONTROLLED ENTITY to fill in our missing TRUE/FALSE value. This is because the GET CONTROLLED ENTITY tile would actually provide us with the Entity our Player is currently controlling which can either be NULL(as in player is not currently controlling an entity) or Entity(in this case the vehicle the player is controlling). NULL will translate to FALSE so we will be able to avoid running code if our player isn't in a vehicle. Now we want to be able to calculate our Player's vehicle speed. Let's make a LOCAL variable so we can name it and be able to resuse it throughout our code. Under VARIABLES, you will see two tiles aside from the CREATE button. The first one is a regular variable and the second one with the two horizontal bars is for arrays. We just want the regular LOCAL variable. Go ahead and drag one inside our IF statement tile. You can click on Variable to rename it to something that would make sense to us. Since we are going to use this one to store our vehicle, we can name it "Player's Vehicle". We already made the code to GET our player's vehicle above for our IF statement's condition. Go ahead and CTRL + Drag that tile into our Default Value empty slot. This means our variable named "Player's Vehicle" is now going to be GET CONTROLLED ENTITY of our Player. Essentially we now have a variable which is our vehicle. To calculate the speed, we want to get the velocity of our vehicle. There is a tile for that which is called GET VELOCITY Vehicle. This will give us a VECTOR of the vehicle's velocity. I would go into much detail about VECTORS but think of it as 3 numbers: X, Y, & Z. To put it simply, think of a graph, but add a height to it. X and Z stand for our horizontal plane and Y is for height. For the vehicles speed, we only care about X and Z for now. Let's make 3 new LOCAL variables: one for X_Velocity, one for Z_Velocity, and one for Speed. I named mine respectively. For our LOCAL variable X_Velocity we want to get the X velocity value. We can use the GET X Vector tile for this. Go ahead and drag a GET X Vector tile and place it inside the DEFAULT VALUE empty slot. Now we are missing the Vector for which it will get X from. Go ahead and drag a GET VELOCITY Vehicle tile into our GET X Vector's empty slot. Lastly, we need to tell GET VELOCITY what vehicle to get the velocity of. We already defined Player's Vehicle as a LOCAL variable above so we can go ahead and drag our local variable into our GET VELOCITY tile. Repeat the same steps above for the Z_Velocity. Make sure to use the GET Z Vector tile instead. Now for a bit of math, using both our X and Z velocity variables, we want to come out with a result....our speed. The algorithm to figure this out is simple, we want to square X and square Z and add them together. To script this, its always best to start at the last step and work our way to the first step, this just makes placing tiles less confusing. Since we need to add our `not yet` squared X & Z values, let's drag over a Addition tile found under NUMBER. You can't search for this tile. Look for the tile with two empty slots with a "+" in between. Place this addition tile in the DEFAULT VALUE of our LOCAL variable Speed tile. Now we need to square our X and Z. Find the POWER tile and place one in each side of the addition tile. Base is the number we are squaring and Exponent is the "to the power of" value. Since we want to square, we will set Exponent to 2. X_Velocity and Z_Velocity can be placed into the Base slots of each POWER tile. Great, now Speed should be calculating using the following logic: ( (x^2) + (z^2) ) = speed. Finally we just need to SET TEXT of the TEXT box(WIDGET) within our custom HUD to the speed we just calculated. Find and place down a SET TEXT Text widget tile. This tile wants us to supply it with a Widget, which is our TEXT box. To provide the SET TEXT tile a Widget, we need to GET WIDGET Custom UI tile. Place this tile within the empty Text widget slot of our SET TEXT tile. Notice that the Custom UI empty slot has "NONE (GAME LOGIC)" with a little dropper to the right. This is expecting a CUSTOM HUD game logic. We can click that dropper and then click our CUSTOM HUD game logic that we physically placed into the world during the first step. Widget ID will now have options for you automatically. Go ahead and click on "NONE" and you should find your TEXT box you named earlier. Select it. Let's provide it with the Player for which it should get the TEXT box of. Remember, the HUD is independent and unique for each player, so we must instruct it using the Player tile from our FOR EACH loop. Lastly, we are missing what the SET TEXT tile should set the text too. We can drag and drop our LOCAL variable Speed. That is it! All you have to do is launch the game using F5 and test it out. Remember, it will only work if you are in a vehicle so you should probably make one real quick ?
  19. Malaka135

    Persistent Variable Storage

    https://community.bistudio.com/wiki/Ylands_Persistent_Storage I was about to make a post asking about this but found it instead. Very useful feature to store information.
×