- Home /
help! isKinematic from false to true on cloned platforms
Hey guys, i'm trying to have a platform fall when it touches a collider which seems to be working fine..but the only problem i have is that because the platform is being cloned when it re spawns it is instantly falling.
Is it possible to have the clone object respawn with isKinematic = true? or have it spawn with refreshed properties? (sorry if i don't make much sense, i'm new to coding) I could be going about this all wrong..so if there's another way i'll appreciate it if someone could point me in the right direction.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DropObjects : MonoBehaviour {
Rigidbody2D rb;
// Use this for initialization
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.name.Equals("ColliderBox"))
{
rb.isKinematic = false;
}
}
}
Thanks for your help!
Answer by Captain_Pineapple · May 14, 2018 at 09:19 AM
just add the line:
void Start()
{
rb = GetComponent<Rigidbody2D>();
rb.isKinematic = true;
}
Though if you instatiate your objects from a prefab just tick the box in the prefab. Then it will always spawn from the settings in your prefab.
Answer by Bleakmountain50 · May 14, 2018 at 01:10 PM
Add Rb.IsKenimatic = true; Rb.useGravity = false; To the start function
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Can Kinematic Object collide with other Kinematic Object? 1 Answer
Multiple Cars not working 1 Answer
Can't get a laser working properly. 2 Answers