How do I make an arrow determine where a sprite goes?

From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • Basically for the adaptation soul, I want it to be like a portal gun, though I'll work on the whole portal part of it later. For now I am trying to make it so that once the arrow stops, it makes the burrow entrance go directly to the closest wall and rotate itself based on which wall it is on. The biggest problem is how to tell the system if the arrow is "pointing" at something or not. Basically I made it so that the arrow orbits around the soul and when I press z it makes the arrow stop, what I am having trouble with is making it so that when the arrow stops, it makes the burrow entrance stick to the wall it is pointing at and at that specific point the arrow is pointing

    In the image I gave the arrow the turret behavior because I was seeing if it could maybe see the wall and know what area to put it in, I know I am probably not making sense but I don't know how to describe it. If you want I could try to share my project so you have a better idea about the code but I am having difficulties trying to make a copy of the project and put it on the post

    This is what happens so far, so it does go on the wall but not the one I want, I want it so the burrow goes to the wall that the arrow is pointing at, the problem is I don't know how to tell the system when the arrow is "pointing" at something and I don't know if I should use the line of sight behavior or not

  • Try out this sample project. It uses a simplistic form of raytracing. That means, it draws a line (casts a ray) from the arrow to the wall. To see the ray, just disable the Ray Destroy action.

    drive.google.com/file/d/1Aj8mMS1FvkMsbzUVTBarXNBRPpXNYWgV/view

  • you can also find an example of raytracing and line of sight combination here:

    youtu.be/TOjp6SPSz7o

    maybe that can help?

  • Try out this sample project. It uses a simplistic form of raytracing. That means, it draws a line (casts a ray) from the arrow to the wall. To see the ray, just disable the Ray Destroy action.

    https://drive.google.com/file/d/1Aj8mMS1FvkMsbzUVTBarXNBRPpXNYWgV/view?usp=sharing

    Ok I just tried it and put it into my project with some minor modifications (like the mouse thing since I don't need that since the arrow I have is orbiting the soul until I press z) and it doesn't work exactly as expected since the walls I have are actually four different sprites in one family, so instead of the ray just going straight at all times, it just goes off course and goes to the nearest wall, as opposed to where it is pointing.

    this is the code that I got so far for the arrow

    and this is what the ray and burrow entrance do when I press z, it just goes down to the nearest wall instead of going straight at all times

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you can also find an example of raytracing and line of sight combination here:

    https://youtu.be/TOjp6SPSz7o

    maybe that can help?

    Sadly I can't access the video since I am on a school computer

  • > Try out this sample project. It uses a simplistic form of raytracing. That means, it draws a line (casts a ray) from the arrow to the wall. To see the ray, just disable the Ray Destroy action.

    >

    > drive.google.com/file/d/1Aj8mMS1FvkMsbzUVTBarXNBRPpXNYWgV/view

    Ok I just tried it and put it into my project with some minor modifications (like the mouse thing since I don't need that since the arrow I have is orbiting the soul until I press z) and it doesn't work exactly as expected since the walls I have are actually four different sprites in one family, so instead of the ray just going straight at all times, it just goes off course and goes to the nearest wall, as opposed to where it is pointing.

    this is the code that I got so far for the arrow

    and this is what the ray and burrow entrance do when I press z, it just goes down to the nearest wall instead of going straight at all times

    First, it is much easier to help with issues like this if you give access to your project.

    Second, I don't think the problem is what you think it is. From your image, the ray is shooting off to the right of the arrow. I also notice the arrow sprite was DRAWN pointing up. In Construct, the default direction of a sprite is facing to the right. I think the issue of the ray shooting off in the wrong direction is caused but your sprite being drawn facing the wrong way. If you edit the sprite image so the arrow is drawn pointing to the right, you'll get the correct result. Draw the sprite pointing to the right, and then, in the layout, rotate it to face the direction you want.

  • ok I will give it a shot, and the reason why I didn't share the project is that I am having difficulties sharing it, probably since this is a school computer and I have tried a lot of things to try to share it like sharing it via google drive (which said that I can only share it with people in my school), I tried dragging and dropping, copying and pasting, and other things.

  • it works now (a side from a few tweaks), Thank you so much and I hope you have a great day!

  • Glad to help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)