playMaker

Author Topic: Spawn point problems with "Create Object" [Solved]  (Read 5775 times)

jayf

  • Playmaker Newbie
  • *
  • Posts: 40
Spawn point problems with "Create Object" [Solved]
« on: June 25, 2014, 01:02:34 AM »
Hi.

I can fire my gun and when it's pointing straight it seems fine, but when I rotate it around and fire, projectiles spawn but do not align with the gun for some reason. (As shown on the screenshots). I'm using an empty Gambe Object parented to the actual gun that spawns the projectiles.

I tried playing around with the spawn coordinates on the "Create Object" action but it doesn't seem to make any difference.




« Last Edit: June 28, 2014, 10:36:40 PM by jayf »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn point problems with "Create Object"
« Reply #1 on: June 25, 2014, 08:22:50 AM »
It looks like the spawn point gameobject isn't moving with the cannon. Are you sure its parented and specified in the action?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jayf

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Spawn point problems with "Create Object"
« Reply #2 on: June 25, 2014, 10:20:45 AM »
Yes it is. I can see in the Scene View (looking at its transform gizmo axis) that it faces wherever the gun faces. What do you mean by specified in the action?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn point problems with "Create Object"
« Reply #3 on: June 25, 2014, 10:40:07 AM »
Hmm weird. There's really only two factors - the spawnPoint has to be a child object of the cannon and the Create Object action has to specify that same spawnPoint gameobject. Theres no need to fill the position or rotation fields if you specify the gameobject.

Maybe a repro scene or screenshot of the action/hierarchy?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jayf

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Spawn point problems with "Create Object"
« Reply #4 on: June 26, 2014, 08:52:46 PM »
Hi.

Ok so here are the screen shots of the Gun, called "Default_Guns" and the bullet spawner called "Default Spawner".

The only actions the guns have is a Set Position and Set Rotation, but they are not that important because the guns are connected to some sort of base, and I'm just making them move and follow that base with those actions.

And the spawner only has a Create Object action set to trigger once it recieves the "Fire" command.

Is this setup ok?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn point problems with "Create Object"
« Reply #5 on: June 26, 2014, 09:41:55 PM »
The only actions the guns have is a Set Position and Set Rotation, but they are not that important because the guns are connected to some sort of base, and I'm just making them move and follow that base with those actions.

This is probably where the issue is at. The spawn point needs to be set as a child of the gun/weapon/cannon in the hierarchy. You could inherit rotations and position with actions but its significantly easier and better to just make the spawn point object an actual child object of the weapon in the hierarchy. Once it is set as a child, there is no need to modify the position or rotation to make it follow the cannon, it is all implied as it is a child object of the parent weapon.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jayf

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Spawn point problems with "Create Object"
« Reply #6 on: June 27, 2014, 04:41:57 AM »
The spawn point is already a child though. I dragged and dropped it on to the cannon in the hierarchy. It's the cannon that has the Set Rotation and Set Position actions applied to it not the spawn point.


jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Spawn point problems with "Create Object"
« Reply #7 on: June 27, 2014, 06:23:44 AM »
It's probably not the cause, but have you checked the rotation in the inspector after you've created the child via 'create object'?  There is a known issue when using that action that sets the rotation of a created object to 0/0.999999/0 instead of 0/0/0 when the field is left blank.  (I spent hours tracking down other weirdness on my project due to this)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn point problems with "Create Object"
« Reply #8 on: June 27, 2014, 10:59:14 AM »
Can you post the scene?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jayf

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Spawn point problems with "Create Object"
« Reply #9 on: June 28, 2014, 06:16:58 AM »
@jess84: In my case the rotations are ok, however the spawned objects x position keeps changing to a certain number not 0.9999 though.

@Lane: Do you mean like this? (See attached screenshot). That's the "complete" scene. To explain my scene (I hope it won't get too complicated :D ).
The cannons are actually spawned by an Empty Game Object, I did that so it is possible to be able to change weapons. Basically the GO has an FSM that tells it what kind of weapons to spawn. Anyway, now the GO is a child of the vehicle but is also attached to one of the Joysticks (I'm using EasyTouch by the way). That way I can control the vehicle, but also control the cannons independently. I made the joystick that controls the cannons a Fire Button as well, so when the cannons look around it also fires at the same time.

There hope that helps clarify things :).

jayf

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Spawn point problems with "Create Object"
« Reply #10 on: June 28, 2014, 10:36:20 PM »
Ok looks like I could solve it myself. I used a simple Cube object (one of the Unity primitives) to act as a proxy for the gun and the projectiles where spawning correctly for some reason even while rotating the cube around. I simply replaced the Cubes mesh with the guns mesh and moved the spawn object to the tip of the barrel and that's it!

Anyways thanks for the awesome support :).