How do I better handle set angle of spawned objects

0 favourites
  • 9 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi there,

    I have run into this a few times and I could use some help on this once and for all. what i have is a base object that I want to face any direction. whatever direction this is facing creates an object offset and in that direction. below shows what I have that works

    however, if i take away that set angle to random and just turn the object to any angle on the screen.. the object insists on spawning vertical at angle 0..

    so what is happening is when this "set angle" action is fired off, then the created object (truck) respects the spawners angle and works great, but nothing I've tried seems to get the created object to simply honor the spawners actual position.

    I'm sure this is super simple, but I can't seem to find what that solution is. I just want the created object to go according to the actual angle of the spawner, not require some scripted position, because I will be doing a lot of level design and testing which would be easiest if I can just move my spawners around and set whatever angle in the layout and those positions work.

    I have several complicated ideas that may or may not work, but I suspect there is something much more simple here I can try.

    Thanks!

    Caleb

  • Ok so digging a little more, it just seems like the problem I'm trying to work through is this..

    I have found a solution, but I'm not happy with it because I think I'm just not getting something right..

    So what I found I had to do was at start of layout, set a global variable of the spawners current angle.. then i set the angle of the spawner to 0.. then i create the respective container objects so they are lined up properly with the spawner then quickly set the angle of the spawner to the global variable..

    this relies on some timers to wait for things to fire off in time so I'm a little concerned the logic might crack if a given device chokes for any given reason. i can't help but think there is a better way.

  • what i have is a base object that I want to face any direction. whatever direction this is facing creates.

    can you rephrase this? I don't really understand what you are trying to do...

    what is TruckA_Spawn? and what's wrong with setting the angle after you create Truck? all object instances are created at the angle of the original object... so if you want to change them you have to Set Angle.

    if you want it to spawn at TruckAspawner's position use the action: TruckA_Spawn->Spawn Another Object instead of System->Create Object. This will also set the position & angle relative to the spawning object.

  • sorry, i corrected that.. incomplete sentence.

    here is what i am working to achieve http://part12studios.com/temp/FredexTest1/

    if you click the colored bars below the truck graphics you'll see they shift the direction of the truck associated with it..

    but my original vision was to make one truck spawner and one box object and have them be able to change on the fly based on a variable.. but i ended up having to break them up into completely unique spawners / truck objects..

    however you do bring up a good point.. the copy being created is set to 0 in my "object" layout. which is a layout i put all of my objects into so i can keep the game layout clean of a bunch of objects just sitting around on the side of the screen.. which leads to your next comment, which is definitely a new action to me.

    regarding "spawn another object".. i've never even noticed that.. that's cool. i see it, but i do wonder how would i then set the relative x and y of the newly spawned object?

    it offers an object, layer and image point, but the objects i'm creating must appear in very specific relative locations.. there is 5 parts to each truck.. the base.. the roof.. the left right and back colliders.. would i then an "on created" and set the x and y that way perhaps?

  • you can just create image points on the truck spawner then Set Position of truck to Object (image point 2 or whatever).

    In my game I have a space ship, when I edit that sprite I made numerous image points. 1 for where the laser will start (just in front of the ship), 2 where the engine exhaust goes (behind the ship), 3 where damage text appears to show how much damage the ship has taken. This last image point it way outside the sprite box, it's a good 100 px away.. but its a good way to get a relative position.

    If I am creating an object that is somehow related to another object. Then I always have the related object "Spawn" the new object.

  • wow that's really cool, but how do you add more than one image point on a sprite? from what i can tell, I can only have one in a given sprite. i don't see a way to add more image points to a single sprite. every time i click somewhere, the image point moves to that spot.

    this is really cool though. I can totally see how this would be a much smarter / organized way to group objects!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also look into using a Container, then both objects will automatically get created, and picked. And look at Pin behaviour. I have a similar scenario where I have an object (invisible) that is always attached to an enemy object, and it has Turret behaviour, etc. On creation of the main object, I Pin the other object to it.

  • part12studios you can have many image points.. hit the "+" sign and it will add more. Also the X/Y coordinates of the imagepoint is shown in little boxes so you can really fine tune it if you want.

    https://www.scirra.com/manual/63/image-points

  • oooooo i see.. sorry i didn't notice the small "image points" window. ok that makes sense. awesome! I'll definitely have to explore that more.

    Thanks!

    Caleb

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