Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Euthyphro

Pages: 1 [2]
16
I'm trying to create an infinite map with pooled layers and chunks using tk2d. So far I've been able to implement a few different procedural generation algorithms to generate the tile map, but now I'd like to make the map infinite with the following logic. Just need to know how to use it with tk2d specifically to programatically control the layers.

The best way I see fit to do this is I plan to pool a new layer with 4x4 chunk set and use them as the player approaches the end of the current layer it is on. For example, I have a map with 4 x 4 chunks in each layer. I was thinking of creating another layer and as the player approaches the border of layer 0, then the next layer with chunkset is used from a pool and placed beside the previous. If a player is walking right and nears the border a layer, the next layer is pulled from the pool, rendered with the tiledata generated from my procedural generation algorithm, and placed. The previous layer is then pooled. If the player walks back or approaches the border again, the layer/chunk set is pooled.

I realize this is not the correct use of a layer but it seems like a fairly simple and quick way to approach this.

I figure I'll only need a pool size of 4 layers, each with 4x4sets of chunks. If the player approaches the border of the bottom right, then you would need to account for the right, bottom right, and bottom edges of the chunk as the player could move in any of these directions, in which case you need to be ready to account for this seemlessly.

i.e. each cube below is a layer from 0 to 3. The little "." is a player moving towards the bottom right. As the player approaches the border of layer 0, layer 1,2,3 are pulled from a pool and rendered with tiledata to seamlessly border layer 0.

x--------xx--------x
|   0      ||     1    |
|         . ||           |
x--------xx--------x
|     2    ||    3     |
|           ||           |
x--------xx--------x

If the player is approaching the left, same thing as above just different position.

x--------xx--------x
|   2      ||     1    |
|           ||           |
x--------xx--------x
|     3    || .  0     |
|           ||           |
x--------xx--------x


So my question in all of this is what is the best way to reposition and control layers programatically with tk2d? Specifically which methods? I find the documentation for tk2d somewhat lacking when it comes to the tilemap methods and classes outside of basic tk2d tilemap functions:(.


Thanks.

17
I'm trying to use Input.mousePosition to get mouse click location, however, I can't seem to convert it to the actual position in-game to move an object.

What I'm trying to do is obtain the actual position in game when a mouse is clicked based on a tk2dtilemap and using tk2dcamera. Transform coordinates are based off of the tilemap. I don't want the pixel coordinates based on lower left side of the screen and top right side of the screen, I'm trying to obtain the actual transform position so I can move an object to the point clicked using i.e. Vector3.Lerp(startVector, mouseClickVector, TIme.deltaTime);

I'm not sure of the math or how it works to convert the Input.mousePosition to the actual transform position? Could someone share how they've done this?


Thanks.

18
Support / Re: NullReferenceException when using tk2dTextMesh
« on: September 13, 2013, 09:23:04 am »
Yes it does. Right now I have text above the object that just says "Hey", I was hoping to be able to control and change that text.

19
Support / NullReferenceException when using tk2dTextMesh
« on: September 13, 2013, 05:54:47 am »
I have the following code which keeps giving nullreferenceexception. It is almost identical to the example given in the documentation. The TextMesh comes attached along with a script called "PlayerObject.cs" (script below) to a prefabricated GameObject. The GameObject is instantiated by Controller.cs (script below). Is there something special that needs to be done to get textmesh working if the gameobject you want a textmesh running on is instantiated from another script?

Code: [Select]
NullReferenceException: Object reference not set to an instance of an object
PlayerObject.Update () (at Assets/Scripts/PlayerObject.cs

PlayerObject.cs script:
Code: [Select]
using UnityEngine;
using System.Collections;
using ClassLibrary;

public class PlayerObject : MonoBehaviour {

public int playerID;
public string objectName;
public tk2dSpriteAnimator spriteAnimator;
public tk2dSprite sprite;
tk2dTextMesh textMesh;

void Start () {
        textMesh = GetComponent<tk2dTextMesh>();
        }
void Update ()
{
                     if(textMesh != null)
                    {
textMesh.text = "TEST";
                     //textMesh.text = objectName;
                       textMesh.Commit();
                      }
}

}


The above gameobject is instantiated from a separate controller script, Controller.cs:
Code: [Select]
GameObject po;
po = (GameObject)Instantiate(Character,vector,Quaternion.identity);
PlayerObject poScript = (PlayerObject)po.gameObject.GetComponent(typeof(PlayerObject));
po.name = goList[i].name;
poScript.playerID = goList[i].pId;
poScript.objectName = goList[i].name;
playersConnectedGO.Add (po);

20
Support / How to change sprite animation at run time with c#?
« on: September 10, 2013, 06:00:58 am »
I'm trying to figure out how to change the sprite animation library of a game object so I can change the current playing animation clip to one from a different library. Can someone please share how to do this in C#?

For example, one Library called "AnimationSetOne" with a dozen clips, and another library called "AnimationSetTwo" with another dozen. How can I change the current library of a game object so I can then use the .Play(anim); method to change a sprite animation clip? I want to be able to do this during run time in c#, could only find a javascript example that didnt work.



Thanks!

Pages: 1 [2]