R0J0hound's Recent Forum Activity

  • That’s the only fancy thing you can do with expressions.

    From most complex

    TypeName(index).behavior.method(param1,param2)

    To most simple:

    TypeName.property

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One way that’s pretty simple is to give your sprite an instance variable “target” and place the waypoints on the layout in the order you want to follow. You could alternately place the waypoints in any order and use an instance variable to set the order.

    Anyways the events would look like this:

    Every tick
    — sprite: move forward 100*dt pixels
    
    Sprite: on collision with waypoint
    — sprite: set target to waypoint.iid+1
    
    Pick waypoint instance sprite.target
    — sprite rotate 60*dt degrees toward (waypoint.x, waypoint.y)

    The 100 is the speed, and 60 is how fast it turns.

  • Is the gltf file you’re using one of the ones included in examples for this plugin?

    I helped with the initial gltf loader part of the plugin. The plugin should be able to load any gltf file saved as embedded from blender, or any other program.

    With the gltf format it has three different variations:

    Gltf + bin

    Gltf embedded

    Glb (binary)

    The loader in this plugin only handles the embedded variation. Which seems like the format you’re using since it works with the Babylon test bed.

    Anyways if you’re able to share the gltf file or a c3p project with the file it may help to find the issue.

    From the error it looks like something isn’t loading correctly.

    Mikal

    It may be something as simple as the the exporter that made the gltf file not adding all the properties that the plugins loader expects. I thought it follows the spec but this may be a case where if that part isn’t there you’d just add it from the other info in the file.

  • int works the same as floor. They both round down, so your probability will be equal for all dice rolls with int(random(1,11)).

    Unless they changed the behavior of int to just truncate the float to an int. But you would only see that with negative numbers.

    int(0.5) = 0

    round(0.5) = 1

    floor(0.5) = 0

    ceil(0.5) = 1

  • Ultimately you can store the data any way you want. In this example I just stored it in a list of number,name;...

    Mainly because it was simple to parse.

    uc5ff84e46bbd754646108bf6012.dl.dropboxusercontent.com/cd/0/get/Ch8oP9p0pQNB3fq9PHr_PHh8G60kt_JsxT-VZeYa3iZSieiI27GeQi_SnaYvVjwzEpLuswJrGgwXmI5R09zTisDShnixiQXmcY13ogFJ1x5TMQD3Hg67Xs-P1f2vyYB2JNQAskVxZuf0a1ifkMhkD7nK/file

  • If you put all those values in an array and just get one at random that would work.

    Array.at(int(random(Array.width)))

    For a more deluxe and compact version you could store the values and weights of each value. The sum of all the weights should be 1.

    Then to randomly pick a value based on the weights you’d:

    1. Generate a random value 0-1

    2. Loop over the array

    3. If the current weight<value? Then subtract the weight from the value and look at the next array position.

    4. If weight>=value then you’re done and the array position you’re on is the value to use.

    Anyways that’s the gist of it at least.

  • Is it all the odd numbers from 1 to 100?

    int(random(50))*2+1

    Or is it a different set of odd numbers?

  • Can’t open the project, but filtering can be done by looping over each entry in the array, checking its length and removing it if needed. The only catch is you’ll want to loop over it in reverse.

    Array: for each x
    Compare: len(array.at(array.width-1-array.curx) >3
    — array: remove at array.width-1-array.curx
  • Skimming over it it doesn’t look like there’s anything preventing it from being ported over.

    The vertex shader portion doesn’t do anything, which is good since construct doesn’t let you modify that anyways.

    The fragment shader has a bunch of uniforms: floats and vec2s which can be two floats.

    The rest would depend on if GLSL is the same for webgl and OpenGL. So there may be a need for some fiddling.

  • That’s kinda what I meant with calculating. You’d effectively be just doing all the math that mouse.x/y does behind the scene. Which would work but I don’t think it provides much benefit.

    As for the lagging of the sprite behind the actual mouse cursor. I thought that was just because of latency between code and the drawn frames or 1/60th of a second.

    An alternative is the to set the mouse cursor from a sprite, which doesn’t lag behind but it’s on top of everything as it’s not truly a sprite then. That reason that doesn’t lag is the operating system is drawing it then which is more input event based instead of frame based.

    Anyways unless the lag you’re seeing is something different. In which case I’m all for tightening it up if possible.

    Edit:

    It just occurred to me that when you scroll some stuff doesn’t get recalculated till the end of the tick. For example viewportLeft(). It possibly could be the same for the mouse(layer).x expression. That could be lag you’re getting which is different than the other one I mentioned.

    You’ll have to test it but assuming that that setting the scroll position causes mouse.x to update till the next tick you can order your events like this.

    Basically before scrolling, save the scroll position to variables. Then after the scroll correct the position.

    Set sprite x to mouse.x

    Set oldScrollx to scrollx

    Set scroll position

    Set sprite x to self.x-oldScrollx+scrollx

  • Best I can tell construct only provides the viewport* expressions to find the width of the view in layout coordinates.

    The browser object, in the c2 docs at least, mention screenWidth and screenHeight as values too.

    With js you can also get the width/height of the html canvas if you really want to handle it from scratch.

    There’s also the system expressions layertocanvasx/y and canvastolayerx/y expressions that may be useful.

    Does it only happen in full screen?

    Honestly for positioning things don’t use absolutex/y. You can use it to see if the mouse moved.

    Otherwise as an exercise in math you can map the absolute mouse position to the layout position in a correct way.

    ///////////

    Intuitively you should be able to put your cursor sprite on any layer and position the sprite with

    Set position to mouse(self.layer).x, mouse(self.layer).y

    And it’ll just work, full screen or not. If it doesn’t then it’s a bug I say.

    You can still utilize absolutex/y to check if there was mouse motion. Like

    Global number oldx = 0
    Global number oldy = 0
    
    Compare oldx <> mouse.absolutex
    Compare oldy <> mouse.absolutey
    — do something because the mouse moved
    
    Every tick
    — set oldx to mouse.absolutex
    — set oldy to mouse.absolutey
  • I mean, absolutex/y doesn’t take into account scaling or parallax at all. That’s why the position will differ from the actual mouse.

    Setting the sprite’s position to mouse.x/y will put it right at the mouse, but i don’t know what layer it uses by default. If you need the mouse position on a certain layer you can use mouse(layer).x/y.

    Or if you’re set on using absolutex/y you can adjust it to match with some trial and error:

    X = mouse.absolutex*scale+offset

    Just by eyeballing it it looks like you could start with a scale of 2 and an offset of 0. But any scale or resolution changes could through that off I’d imagine.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound