'I have a script which I have used on two objects and, Rigidbody2d.bodytype changes to static but is not changing back to dynamic for one game object
Here is my script code:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ControlSpike : MonoBehaviour
{
private static ControlSpike _instance = null;
public static ControlSpike Instance { get { return _instance; } }
public Rigidbody2D spikeBody;
public void Awake()
{
_instance = null;
if (_instance != null && _instance != this)
{
}
else
{
_instance = this;
}
spikeBody.bodyType = RigidbodyType2D.Static;
}
// Start is called before the first frame update
void Start()
{
spikeBody.bodyType = RigidbodyType2D.Static;
}
// Update is called once per frame
void Update()
{
}
public void DropSpikes()
{
if (DrawingManager.Instance.paths.Contains(DrawingManager.Instance.clone) && VehicleSimpleControl._instance.RacePress)
{
spikeBody.bodyType = RigidbodyType2D.Dynamic;
spikeBody.gravityScale = 10f;
}
}
}
The rigidbody.body type changes bodytype of one gameobject to dynamic but doesnt change the bodytype of the second gameobject to dynamic. Both get changed to static though. What could be wrong? Thanks in Advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
