Skip to content

Instantly share code, notes, and snippets.

View sampattuzzi's full-sized avatar

Samuel Pattuzzi sampattuzzi

  • Freelance
  • Cambridge UK
  • 18:37 (UTC +01:00)
View GitHub Profile
@sampattuzzi
sampattuzzi / FPSCharacter.cpp
Created April 3, 2020 10:47
Enable ragdoll on a character with weapon
void AFPSCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (Health <= 0 && Controller != nullptr)
{
// Shouldn't be in control after we die.
DetachFromControllerPendingDestroy();
// Capsule collisions off

The solution given is a bit out of date. If you try to move the "Epic Games" directory to remove the space and symlink it, it will cause lots of errors when launching projects of generating XCode projects.

Just to recap, the problem is that Unreal generates the XCode project in the wrong format. It leads XCode to believe that the space in the path is indicating a new path. So XCode cannot find the files to index for autocomplete.

The least fragile thing to do is fix the XCode project itself. However, doing this manually is a pain as it's a very long list of include files. So I created a script that will update the project for you. Here's how to use it:

  1. [Download the python file][1]
  2. Save it at the root of you project.
  3. Open a terminal an cd to the project root.
  4. Run python ./fix_xcode_autocomplete.py
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
int main()
{
std::cout << "Hello world\n"
return 0;
public class MusicPlayer : MonoBehaviour {
static MusicPlayer instance = null;
void Start () {
if (instance != null) {
Destroy (gameObject);
print ("Duplicate music player self-destructing!");
} else {
instance = this;
GameObject.DontDestroyOnLoad(gameObject);
class Bananas : monobehaviour {
bool isFruity;
static bool isYellow;
}
firstBanana.isFruity = true;
firstBanana.isYellow = true;
secondBanana.isFruity = false;
secondBanana.isYellow = false;
Bananas firstBanana = new Bananas();  //This makes a new instance of the class Bananas
Bananas secondBanana = new Bananas(); //This makes a second clone completely separate to the first one.
firstBanana.isFruity = true;
secondBanana.isFruity = false;
class Bananas : monobehaviour {
bool isFruity;
}
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class LevelManager : MonoBehaviour {
public float timeTillNextLevel = 0.0f;
void Update () {
if (timeTillNextLevel > 0)
void UGrabber::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
// Get player view point this tick
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
OUT PlayerViewPointLocation,
OUT PlayerViewPointRotation