Jump to content

Action Group Activation


Recommended Posts

I mean that when the part / vessel illuminated by the Sun, the method returns true, and vice versa.

I'm not sure but I don't think there's a method specifically doing that, since lighting of a part is handled directly to the part model instead of the part as a whole.

I don't have a good idea how to do what you want - it would require some knowledge on Unity Engine - but I did find something that might be helpful: http://docs.unity3d.com/Documentation/ScriptReference/Light.html

Link to comment
Share on other sites


using System;
using UnityEngine;
using KSP;

public class ModuleAutomatedLight : PartModule
{
bool isActive;

public override void OnAwake()
{
Debug.Log("Part with ModuleAutomatedLight succesfully loaded.");
}

public override void OnUpdate ()
{
isActive = false;
if (isActive == false && FlightIntegrator.underDirectSunlight == true) //error!
{
Vessel.ActionGroups.SetGroup(KSPActionGroup.Light, true); //error!
isActive = true;
}else if (isActive == true && FlightIntegrator.underDirectSunlight == false) //error!
{
Vessel.ActionGroups.SetGroup(KSPActionGroup.Light, false); //error!
isActive = false;
}
}
}


Mono returns 4 errors to me. I did not write errors because MonoDevelop wrote them in Russian. Why, I do not know.

Link to comment
Share on other sites

Oh man...

I wrote "Vessel" because it's the class name. You need to use the object. Should be "vessel" here

Same with FlightIntegrator, it is a class. The object should be (haven't tried) vessel.flightIntegrator

I would suggest you learn more about C# before writing a plugin. And get an English version of C# compiler so that you know what happens when you get an error.

Link to comment
Share on other sites

Hi everybody

For some time, I have wanted a "solar wind sail" for deep space missions, but in my attempt to create it (by extending ModuleDeployableSolarPanel), I have ran into the problem, that KSP won't allow me to modify the ships speed when warping is active, neither through directly modifying rigidbody.velocity or by rigidboyd.AddForce.

The solar sail should barely produce any force, so any speed change would be very slow.

Does anyone have any suggestions, except not warping?

Best regards

RCSub

Link to comment
Share on other sites

Hi everybody

For some time, I have wanted a "solar wind sail" for deep space missions, but in my attempt to create it (by extending ModuleDeployableSolarPanel), I have ran into the problem, that KSP won't allow me to modify the ships speed when warping is active, neither through directly modifying rigidbody.velocity or by rigidboyd.AddForce.

The solar sail should barely produce any force, so any speed change would be very slow.

Does anyone have any suggestions, except not warping?

Best regards

RCSub

Perhaps you can do some maths with the orbit. Never tried myself, so don't ask me how to do it, but I think you may find the source code of HyperEdit interesting

Link to comment
Share on other sites

Hi everybody

For some time, I have wanted a "solar wind sail" for deep space missions, but in my attempt to create it (by extending ModuleDeployableSolarPanel), I have ran into the problem, that KSP won't allow me to modify the ships speed when warping is active, neither through directly modifying rigidbody.velocity or by rigidbo[dy].AddForce.

The solar sail should barely produce any force, so any speed change would be very slow.

Does anyone have any suggestions, except not warping?

Best regards

RCSub

AFAIK all rigidbodies whithin a vessel will be kinematic while timewarping (except if you use physics timewarp), hence physics will not be applied to the vessel while timewarping.

You could possibly modify the orbit directly. You could calculate acceleration from the vessel mass and whatever force the sail should apply.

I quickly threw together a small proof of concept plugin, you can view the source here.

Since the sail wont be generating power, you don't need to be running all the stuff in ModuleDeployableSolarPanel, so I just extended ModuleAnimateGeneric and did the obstruction detection and area-facing-the-sun calculations myself.

Note that the plugin I've linked is very much something I threw together, I haven't tested it in-game, so it might very well have some bugs, and modifying the orbit velocity in the way I've done was just an idea, I don't really know whether it will work or not (it might be entirely impossible or, more likely, something different/more needs to be done with the orbit). Maybe you'll be able to get a couple of hints from the HyperEdit source.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...