Raycast API

coleislazy

  • *
  • Posts: 2607
I had to stumble through the raycast API recently, and it was a bit of a pain, so I though't I'd package it up into a more user-friendly set of blocks.

How to Install Extensions

Check out the Readme file in the extension's folder for more information on how to use the blocks and what values they return.

If you have any suggestions for improvements, I'd love to hear them! Bugs are welcome, too!


Ninjadoodle

  • Posts: 313
Hi coleislazy

Thank you for creating this extension :)

Is there a way for the api to return whether it hit a tile?

I'm trying to check where there is a wall tile between a player and an explosion.

Thank you!
It's all fun and games until somebody get's a shuriken in their eye!

coleislazy

  • *
  • Posts: 2607
Tiles are just actors of a different name to Stencyl. I believe the actor will be named "Terrain" if its a tile. To get the name, just convert the returned actor to text. This may be different for a tile placed by the tile API.

Ninjadoodle

  • Posts: 313
Awesome, thank you for your quick reply :)

So, if I wanted to check that there is 'nothing' between a player and an explosion, would I create a list and check if that list is empty?

Thank you again or your help!
It's all fun and games until somebody get's a shuriken in their eye!

coleislazy

  • *
  • Posts: 2607
That would be one way. You may be able to use the nearest cast and check if the returned value is null, also.

Ninjadoodle

  • Posts: 313
So, I had a play around and I can't seem to get it working haha. I keep getting ...

[LOG] Missing: first actor on line from x1: %0 y1: %1 to x2: %2 y2: %3.help

Putting the first actor block and trying to 'print' it.

I don't even know where to look for what I might be doing wrong :)
It's all fun and games until somebody get's a shuriken in their eye!

coleislazy

  • *
  • Posts: 2607
I saw in another thread that you may have fixed your problem. Is that correct?

Ninjadoodle

  • Posts: 313
Sorry, I had to go out before I had a chance to post here.

It was the fact that testing in the browser doesn't print statements for me.

I managed to get things working now :)

Thank you!
It's all fun and games until somebody get's a shuriken in their eye!

Ninjadoodle

  • Posts: 313
I just wanted to say thanks for your cool extension! With your help I managed to do what I wanted for a while.

I have an explosion which checks whether there is a wall between itself and an enemy and inflicts damage according to distance.

Thank again!
It's all fun and games until somebody get's a shuriken in their eye!

wolkilula

  • Posts: 12
Hi there,

I installed the extension and try to use a raycast, to detect objects.
But if I use one of the raycast-blocks I'll get a null pointer exeption:

TypeError: Error #1009: Der Zugriff auf eine Eigenschaft oder eine Methode eines null-Objektverweises ist nicht möglich.
    at RaycastAPI$/rayCast()[C:\Program Files (x86)\Stencyl3\plaf\haxe\extensions/raycastapi/RaycastAPI.hx:60]
    at MethodInfo-5489()[Source/scripts/Design_244_244_heroLogic.hx:82]
    at com.stencyl::Engine$/invokeListeners2()[C:\Program Files (x86)\Stencyl3\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:3853]
    at com.stencyl.models::Actor/innerUpdate()[C:\Program Files (x86)\Stencyl3\plaf\haxe\lib/stencyl/1,00/com/stencyl/models/Actor.hx:1454]
    at com.stencyl::Engine/update()[C:\Program Files (x86)\Stencyl3\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2376]
    at com.stencyl::Engine/postUpdate()[C:\Program Files (x86)\Stencyl3\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2585]
    at com.stencyl::Engine/onUpdate()[C:\Program Files (x86)\Stencyl3\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2578]


I use the block with a print block. I don't get it. I've tried different blocks and combinations but it is still this problem.

Hope you can help me :]

Jon

  • *
  • Posts: 17524
This stuff only works with Stencyl 3.0 right now. I've started moving parts of the 3.0 forum to the public, so I apologize for ay confusion this causes.

UnrealCanine

  • Posts: 244
Sorry for bringing up an old topic, but how would I use the 'all actors' in order to find whether an actor hs line of sight with another

MichaelPel

  • *
  • Posts: 458
Yes hello. Using this extension breaks any event placed under the get actor event. Why would this be?

MichaelPel

  • *
  • Posts: 458
Here's the log. It says other things are broken which work fine if you dont use raycasting