Announcement

Collapse
No announcement yet.

Cant set up StaticMeshComponent as a CollisionComponent for spawned actor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cant set up StaticMeshComponent as a CollisionComponent for spawned actor

    Hallo! I have tried many methods trying to make my custom collision work. Only standart cyllinder collision works fine, but its not enough.
    I have created simple mesh in 3ds max, added collision there using MCDCX_ prefix, and it collides absolutly fine with other actors and same meshes if I add this mesh to level in Editor. But, when I spawn two actors using unrealscript, both have this mesh by default -> they flying through each other but collide with level geometry and even with same meshes added in Editor. One is not moving at all, and second moved by MoveSmooth in Tick, not SetLocation =)

    Before and after (both are spawned, green moves through red):



    Code that spawns actor to level:

    Code:
    class CreateOverlay extends Actor
    	placeable;
    
    var Overlay OVL;
    var vector Offset;
    
    function AddOverlay()
    {
    	local rotator SpawnRotation;
    
    	SetRandomLocation();
    	SpawnRotation.Yaw = SetRandomRotation();
    
    	OVL = spawn( class'Overlay', self,, ( Location + Offset ), SpawnRotation )
    }
    
    function SetRandomLocation()
    {
    	Offset.X = 100 * Rand(5);
    	Offset.Y = 100 * Rand(5);
    }
    function int SetRandomRotation()
    {
    	return Rand(4) * 16384;
    }
    DefaultProperties
    {
    	Offset=(X= 0, Y=0, Z=-100)
    	Begin Object Class=SpriteComponent Name=CrOvSprite
            Sprite=Texture2D'EditorResources.S_NavP'
            HiddenGame=True
        End Object
        Components.Add(CrOvSprite)
    }
    And next is spawned "Overlay" actor's code

    Code:
    class Overlay extends Actor
    	placeable;
    
    var vector OVLVelocity;
    
    auto state Move
    {
    	function Tick ( float DeltaTime )
    	{
    		MoveSmooth ( OVLVelocity * 10 * DeltaTime);
    	}
    }
    
    DefaultProperties
    {
    	OVLVelocity=(X=100, Y=100, Z=0)
    
    	bCollideActors=true
            bBlockActors=true
    	bCollideWorld=true
    
    	 Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
                 bEnabled=TRUE
             End Object
        Components.Add(MyLightEnvironment2)
    
        Begin Object Class=StaticMeshComponent Name=MeshOverlay
            StaticMesh=StaticMesh'Kdavraty.Mesh.complex_IL'
            Materials(0)=Material'EditorMaterials.WidgetMaterial_Y'
            LightEnvironment=MyLightEnvironment
            Scale3D=(X=2,Y=2,Z=2)
    	CastShadow = false
        End Object
    
    	CollisionComponent=MeshOverlay
            Components.Add(MeshOverlay)
    
    	//MeshOverlay.SetActorCollision(true, true)  <- found this somewhere, not workin, causes warning by compilation
    }
    So... whats wrong with it?
    thanks!

    #2
    try adding collision to your mesh object

    Begin Object Class=StaticMeshComponent Name=MeshOverlay
    StaticMesh=StaticMesh'Kdavraty.Mesh.complex_IL'
    Materials(0)=Material'EditorMaterials.WidgetMateri al_Y'
    LightEnvironment=MyLightEnvironment
    Scale3D=(X=2,Y=2,Z=2)
    CastShadow = false
    CollideActors = true
    BlockActors = true
    BlockRigidBody = true

    End Object

    also make sure it actually has collision in the static mesh editor

    Comment


      #3
      SetActorCollision can't be used in the default properties block, it's a template syntax for assigning default values and defining basic objects, it doesn't execute unreal script code.

      I don't see anything obviously wrong in the collision, but then I haven't woke up yet But, judging by your shapes I can tell you that when it is working it won't work the way you expect. When an actor moves using MoveSmooth it uses the bounding box of the CollisionComponent, not the actual shape.

      Comment


        #4
        Originally posted by tegleg View Post
        try adding collision to your mesh object

        Begin Object Class=StaticMeshComponent Name=MeshOverlay
        StaticMesh=StaticMesh'Kdavraty.Mesh.complex_IL'
        Materials(0)=Material'EditorMaterials.WidgetMateri al_Y'
        LightEnvironment=MyLightEnvironment
        Scale3D=(X=2,Y=2,Z=2)
        CastShadow = false
        CollideActors = true
        BlockActors = true
        BlockRigidBody = true

        End Object

        Thanks, but I have already did it before, and there is no difference. I think that Its just duplicating of information, "bCollideActors=true" and "bBlockActors=true" do same thing (or not?). anyway thats not solution.
        Originally posted by tegleg View Post
        also make sure it actually has collision in the static mesh editor
        It has collision, i can see it in mesh editor and test in editor, but it works properly only if I add this mesh in Editor. If I spawn it using unrealscript, it doesnt collide with other same spawned meshes. (but collide with objects added in Editor)

        Originally posted by Spoof View Post
        SetActorCollision can't be used in the default properties block, it's a template syntax for assigning default values and defining basic objects, it doesn't execute unreal script code.
        Thanks for axplanation!

        Originally posted by Spoof View Post
        I don't see anything obviously wrong in the collision, but then I haven't woke up yet But, judging by your shapes I can tell you that when it is working it won't work the way you expect. When an actor moves using MoveSmooth it uses the bounding box of the CollisionComponent, not the actual shape.
        Before I used a simple square instead if this shape, no difference

        Comment


          #5
          Originally posted by paraschute View Post
          Thanks, but I have already did it before, and there is no difference. I think that Its just duplicating of information, "bCollideActors=true" and "bBlockActors=true" do same thing (or not?). anyway thats not solution.
          The component properties and actor properties work together. Actor properties act as a 'master switch'. A logical way to think about it is...

          Code:
          // psuedocode, don't use this...
          
          if ( Actor.bCollideActors )
          {
          
              if ( Actor.Component.CollideActors )
              {
          
                  // this component is a candidate for collision
              }
          }

          The reason why adding them makes no difference is because they're already set in the StaticMeshComponent default properties.

          There is a big difference between bCollideActors and bBlockActors: http://udn.epicgames.com/Three/Colli...icalGuide.html

          Comment

          Working...
          X