How do I make several instances of an object that is made of multiple pinned objects?

0 favourites
  • 11 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I've coded and designed a snake for a shmup game I'm pretty happy with.

    gyazo.com/ea39742e5f67a376be0c974c35c6f0ff

    I know the code is not the cleanest, but I got the movement I wanted and that was my first step

    gyazo.com/af7ce9a7cea3c9eb0a20b061ec5be0b0

    Right now, I cannot just copy paste the sprites of the first snake and roll as that will cause everything to pin to itself twice and mess with the movement.

    I want to create one sheet of code which would let me have independent snakes.

    This way I'd be able to adjust each one's movement independently.

    thanks so much for replies, also happy pride friends!

  • Not sure what the problem is? Create a second snake and pick it with events, or create completely new objects for a second snake it's up to you.

  • Since you have all snake parts as separate objects, you need to add them to a container. Then in the "SnakeHead On Created" event all its parts will be picked automatically, and pinned correctly to each other.

    You may need to add "For each SnakeHead" to your event #4

  • Tag system for flexible use & modularity with only 1 object family:

    dropbox.com/s/xfdap5rv93wusie/snake_body_pin.capx

  • Not sure what the problem is? Create a second snake and pick it with events, or create completely new objects for a second snake it's up to you.

    Right, I understood this was a possibility but this is sort of what I wanted to avoid. I envision levels with potentially 10+ instances of snakes with different movement and I want to take the opportunity to learn how to avoid remaking it entirely every time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Since you have all snake parts as separate objects, you need to add them to a container. Then in the "SnakeHead On Created" event all its parts will be picked automatically, and pinned correctly to each other.

    You may need to add "For each SnakeHead" to your event #4

    I just tried this and it works quite well! gyazo.com/0a82f56b6096b22f7227e4d4afabe97b

    there seems to be one issue though where the snake head with inverted movement is flipped. I think there's an equation to determine angle of movement which I should probably be using to determine the angle of the snake head instead of just using the behavior's set angle.

  • Tag system for flexible use & modularity with only 1 object family:

    https://www.dropbox.com/s/xfdap5rv93wusie/snake_body_pin.capx?dl=0

    This looks like exactly what I'd want! I'll try reworking this solution for myself tomorrow morning as it's getting quite late for me!

  • Glad if grouping instances by tagging them gave an ease for something to work with.

  • Oh, by looking at alextro's solution I realized something I could do is have the snake start one section ahead of the snakehead, and have the snakehead point to it.

  • Yes you may ended up creating train instead of snake.

  • Since you have all snake parts as separate objects, you need to add them to a container. Then in the "SnakeHead On Created" event all its parts will be picked automatically, and pinned correctly to each other.

    You may need to add "For each SnakeHead" to your event #4

    Hey, so I had a followup question on this. I have an effect I implemented previously where there's a nice chain explosion on the snake. with the containers, every object in the container is destroyed if another object is destroyed. this makes it hard to use my chain explosion. is there a way to modify my container to allow it to let other objects stay in the scene when destroyed?

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