Euclidean TRPG Assistant (ETA)

Alright, I’ll go with the geometry-based approach instead. I feel really silly for not thinking of that sooner.

So…really stupid question, but how do I make cubes with transparent materials? I made a couple of transparent .pngs with white and cyan outlines, and I uploaded them to my project, but I can’t seem to make the flat cubes (tiles) transparent, despite the fact that the texture/material itself should be transparent.

https://playcanvas.com/project/596207/overview/eta-play-mode

Re-starting with the geometry-based approach. Using swatty’s camera scripts (still need to figure out the whole “Hammer.js” thing [I tried importing Hammer.js into a different project, and it didn’t recognize it; though it seems like it works just fine without Hammer]).

https://playcanvas.com/project/596207/overview/eta-play-mode

Need to make a script that will spit out the distance between the center of two squares (not doing edge-to-edge measurements for now).

@swatty
Attempting to use collision picking to select tiles, as per https://developer.playcanvas.com/en/tutorials/entity-picking/

However, it isn’t working (the tile doesn’t pulse like in the tutorial). I’m using the blue “selected_squares” to test this, and I’ve enabled both collision and rigid body on said tile. As I got the script from the above link (which was linked on https://developer.playcanvas.com/en/tutorials/entity-picking/) on May 2017, it may be possible that the script is outdated. Alternatively, I put the script in the wrong place, or I accidentally broke the very nature of physics and ray casting/collisions in my game.

Also, I’ll be wanting the tile edges to switch color (from white to cyan), which means I’ll have to somehow swap the textures out.

https://playcanvas.com/project/600366/overview/picking-test
Managed to make the tiles able to change color, from white to cyan, back again. However, not much else happens when a tile is “selected.” So I’ll have to keep working on it. Next step is to save the position of the selected tile to a variable for use with the ruler function.

Big thanks to @Swatty for helping me out big time. Hopefully, I can continue to improve my skills, and eventually be able to help y’all out with your projects, too!

Thats just used for the touch events on mobile devices, so yeah it will complain but still work on your computer unless you have a touchscreen :wink:
It shouldnt throw an error but my script logs a warning for the missing dependency, if I remember correctly.
But to get the touch events working you should import the library & ensure its loaded before the camera script in your scenes script loading order.
https://developer.playcanvas.com/en/user-manual/scripting/loading-order/

Just to ensure nobody else falls into the same issue, that isnt the case :wink:
I setup a quick test project and made a quick & dirty example script with some comments in the code for the given usecase. If somebody else is struggling with similar issues it might help: https://playcanvas.com/project/600356/overview/camera--picking-example

Good to hear, looks already way different than two days ago. Like where you are going & glad that I could help you out. If you have some other questions, feel free to ask.

If somebody is wondering, we have been mailing a bit back & forth, was just a bit too busy to check the forum :smiley:

Greetings,

Martin

EDIT: I can’t believe it! The fragging buttons are getting in the way of the tiles! Evidently they’re a lot bigger than they look. I’m working on figuring out how to control their size/bounds better.

Yaustar wrote a short script that solved the previous issue. Big props to him.

I’m currently trying to make the rulerActive variable defined at all times.

image

image

image

image

image

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

This concludes today’s update.

Never mind, I got it.

Thanks to whoever wrote this tutorial.

Refer to this post on getting to grips with the API: How to refer to different parts of the API while scripting

1 Like

I have completed the token spawning functionality. Now I have to make the token moving functionality, the initiative functionality, and the map editing functionality.

1 Like

Token moving functionality complete.

ETA’s play mode (ruler, initiative, token spawner) is complete, sans any changes that will have to be made for multiplayer.
https://playcanvas.com/project/600366/overview/eta-play-mode

Thanks again to @swatty, @yaustar, and everyone else who has helped so far. Your assistance has been completely invaluable, and I will pay that knowledge back. As well as delivering a useful tool for your TRPG sessions, too.

ETA’s map editor functionality is not completely done, but I have to turn in this project soon, so I’ll just leave it be for now so I can start working on the multiplayer functionality.

Currently, users can add tiles to the scene, but cannot delete them. Barring a sudden flash of insight, I will not be adding a tile deletion functionality until after I turn this project in (April 26).

W8 so its possible to manipulate the text elements on certain button clicks? or if the player gets damaged?

Oh, yeah. I got the text elements to change. Sorry if I didn’t mention that earlier.
Project editor link: https://playcanvas.com/editor/scene/700970
Here’s the script that I attached to my text entity (the one labeled “Distance” by default).

var DistanceText = pc.createScript('distanceText');

// initialize code called once per entity
DistanceText.prototype.initialize = function() {
    // find our widget
    this.distText = this.entity.findByName('Distance_Text');
};

DistanceText.prototype.Print = function(number) {
    this.distText.element.text = number.toFixed(2);
};

DistanceText.prototype.PrintEtc = function(string) {
    this.distText.element.text = string;
};

And here’s an example script of me changing the script from another script:

// use the 3D distance formula to find the distance between the two tiles: sqrt( (x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2 )
var distance = Math.sqrt(Math.pow((x2 - x1),2) + Math.pow((y2 - y1),2) + Math.pow((z2 - z1),2));
// call the "Print" function declared in the distanceText script to populate the Distance_Text textbox with the distance
this.app.root.findByName("Distance_Text").script.distanceText.Print(distance);

Print() is used for turning numbers into strings to be printed, and PrintEtc() is used for printing anything that’s a string to begin with. I’m sure if I was a bit less lazy, I could have made a single function that could handle both, but…

I’m using this tutorial to try and grok Multiplayer.
While the tutorial uses a single camera that all players share, and instead uses capsules as the player entities, I instead want the camera entity to be unique to each player, and for the tokens to be freely movable by anyone (the logic being that if Flopnar the Raging Barbarian tackles Shay’tan the Twink Wizard, Flopnar’s player should be able to move both of their tokens, even if Shay’tan’s player is away from their computer, cooking ramen). But I fear that cloning the camera entity (which has hundreds of lines of script attached to it) will slow down the game considerably. However, I don’t have time to re-write 2/3 of my project, so I’ll just have “other” cameras and hope for the best.

EDIT: I see no possible way this could go wrong.
image

The first build of ETA is available here!

I’ve turned in ETA, and I’m graduating with a B.S. in Information Technology. My commencement is on Wednesday. And now that I’ve caught up on my sleep, I’m going to keep working on ETA in my spare time. The first thing I’ve gotta do is make the multiplayer component work. So expect to see me in the forums again here soon.

2 Likes